开发者

BASH while line numbers in file is smaller than x

开发者 https://www.devze.com 2023-04-07 22:32 出处:网络
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

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

精彩评论

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