请问达人grep有无“与”“或”选项? 例如查找一文件中包含的“aaa”" 和 "bbb"字符串的行如何弄呢。笨方法是执行两次grep 但是这样源文件中的aaa bbb 关系看不出来。例如原文aaa c=1; bbb c=1 ;。。。; aaa d ;。。。。。。。。。bbb d; aaa d 。我想提出来的aaa行和bbb行顺序和原文一致,如果用两次grep就不对了 最好大家能给出用grep的方法。awk和sed也欢迎
by fortuneteller - Shell - 2008-08-05 08:53:30 阅读(2630) 回复(10)
abcd="A|D|a1|a2" cat file1.txt |egrep "$abcd" > file2.txt 为什么file2.txt是空。 file1.txt文件内容: A 21123 b 923342 D 3213412 a1 2231243 a2 98766 B 892317
grep -c string1 file grep -c string2 file 如果写到一行里 grep -c string1或string2 file 同样,与和非操作怎么写?
在LINUX,AIX,HP—UX下,都可以用grep -E实现grep的“或”条件查找, 即: grep -E condition1|condition2|condition3..... 但是在Solaris9.0下,这个功能却无法实现,因为grep无法带"-E", 如果想在Solaris下实现这个功能,grep该如何写啊?谢谢各位了,这个问题困扰我好久了。
格式: grep -E 'A1 | A2 | A3' filename 用这种方式去匹配文件, 其中的 A1 A2 A3的个数有限制吗? 是否可以无限制的扩展为 grep -E 'A1 | A2 | A3 | A4 | .......| A100' filename 急需知情人解答 谢谢。
问题:通过下面命令可以把结果输出到文件里 vmstat > /file top |tee -a /file 可是下面却不行, vmstat 1 >/file或vmstat 1 |tee -a /file top -d 1| grep Mem |tee -a /file或top |grep Mem >/file 请教如何把vmstat 1或top | grep Mem 的结果输出到文件里?
成功的样例 wld.log Table CIN_CAPACITY_INFORMATION_NEW: 312 Rows successfully loaded. 0 Rows not loaded due to data errors. 0 Rows not loaded because all WHEN clauses were failed. 0 Rows not loaded because all fields were null. 如果下面这三行都是以0开头,表示没有失败的记录,即全部成功,如何用grep命令表示 0 Rows not loaded due to data errors. 0 Rows not loaded because all WHEN clauses wer...
Apache/2.0.50 (Gentoo/linux) Server at www.apache.org Port 80 (Gentoo/linux)或(RedHat/linux)或(Unix)字样是整样编译到apache里的啊?可以修改吗?