Search code examples
linuxbashwc

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 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 ]

Solution

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

    try this?