Chinaunix

标题: firefox打开grep的结果 [打印本页]

作者: luofeiyu_cu    时间: 2012-10-05 10:33
标题: firefox打开grep的结果
本帖最后由 luofeiyu_cu 于 2012-10-05 10:36 编辑

grep -l "mysed" /home/test
可以找出所有包含mysed的文章,假定有3个结果:/home/test/sed1,/home/test/sed2,/home/test/sed3
1.用firefox打开第2个结果
2.用firefox打开所有的结果

请问,如何用shell命令来完成?
作者: rdcwayx    时间: 2012-10-05 12:03
我的环境下,firewall 的路径是: /usr/sfw/bin/mozilla。
  1. 1.用firefox打开第2个结果

  2. grep -l "mysed" /home/test |awk 'NR==2' |xargs -i /usr/sfw/bin/mozilla {}

  3. 2.用firefox打开所有的结果

  4. grep -l "mysed" /home/test |xargs -i /usr/sfw/bin/mozilla {}
复制代码

作者: L_kernel    时间: 2012-10-06 20:06
第二个结果
  1. grep -l "mysed" /home/test | sed -n '2p' | xargs firefox
复制代码
所有结果
  1. firefox `grep -l "mysed" /home/test`
复制代码





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2