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 the 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}')
尝试这个?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.