ls -Flt | awk '{print $5, $9}' | while read filesize
do
echo $filesize | cut -d ' ' -f1 | read size
if [ $size -ge 204800 ]
then
echo $filesize
fi
done
while executing getting the error
filesize.sh[4]: test: Specify a parameter with this command.
But the output is displaying. Can anyone help me if anything wrong in this code.
ls -Flt | awk '{print $5, $9}' | while read filesize
with
ls -Flt | grep -v ^total | awk '{print $5, $9}' | while read filesize
The 'ls -Flt' is a long listing that produces a 'Total' row at the beginning of the listing which only has two fields - hence the fields you are extracting via awk are empty and the test command is comparing nothing to '204800'.