Monday, 19 August 2013

finding file size for a conditional

finding file size for a conditional

I'm trying to write a conditional statement so that if a file is greater
than 1GB it prints the name of that file, in a file, and skips processing
it.
#!/bin/bash
for f in *.dmp
do
if [ ! $(stat -c %s $f > 1000000000) ]; then
name=`basename ${f%.dmp}`
if [ -f ../tshark/$name.dat ]; then
echo "file exists, moving on...";
else
echo "Processing" $name;
tshark -PVx -r "$f" > ../tshark/$name.dat;
echo $name "complete, moving on...";
fi
else
echo $f "too large";
echo $f "\n" > tooLarge.txt;
fi
done
The problem is ! $(stat -c %s $f > 1000000000) isn't working.
I'd appreciate any suggestions.

No comments:

Post a Comment