开发者

grep file and save whole line into variable

I'm开发者_如何学Go trying to simply grep lines in a file. If the line has the word "status" in it, I need to parse it out and do things with it inside of my for loop. The problem is that there are spaces inside the line, so I'm only getting one word at a time. This loop is actually nested inside of another for loop, which is only reading certain files in my directory. I need to know how to read the whole line, with spaces and everything.

    for STATUS in `grep status $FILE`
        do 
           #do stuff
        done


grep status $FILE | while read line; do
    echo $line ## or do whatever with it
done
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜