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?
精彩评论