开发者

BASH while line numbers in file is smaller than x

i want to make a loop that reads some files and i want it to stop when wc output is smaller than 5 in this case the file "file" contains 开发者_StackOverflowthe names of the files that will be worked on

for i in `cat file`
do

echo printing $i ...
a=`wc $i`
while [ $a -gt 5 ]
do
echo 3
sleep 10
done

done

this part is not working

a=`wc $i`
while [ $a -gt 5 ]


Your going to want to use wc -l to get the line count of the file. Also you will want to decrement $a so you don't have an infinite loop.


a=$(wc -l $i|awk '{print $1}')

try this?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜