分页: 1 / 1

grep 多字符查找问题

发表于 : 2015-01-06 22:30
h7054
我写了个grep 多字符查找脚本 但是运行后死活没反应,请问大牛知道这是怎么回事吗?

Re: grep 多字符查找问题

发表于 : 2015-01-07 15:05
millenniumdark
代碼不要用圖片,還有你 mac.text 的內容也貼一下

Re: grep 多字符查找问题

发表于 : 2015-02-26 14:38
zhangxiaofir

代码: 全选

[test]$ cat test.txt 
a
b
c
[test]$ cat string.txt 
a
[test]$ cat seed.sh 
while read string
do
echo "grep $string"
grep "$string" test.txt
done <string.txt
[test]$ sh seed.sh 
grep a
a
建议使用sh -x 来调试脚本 或者在必要的地方echo输出变量

Re: grep 多字符查找问题

发表于 : 2015-03-06 16:23
infidel
楼主把grep命令用错了吧
应该是
echo $string |grep -w -e '*.log'

楼主的意思是从string里面找log结尾的东西对吗?