Search Here

Shell Script to display name of the files whose size is within the range B1 and B2 bytes. B1 and B2 bytes are supplied as command line arguments


if [ $# -eq 2 ]
then
    B1 = $1
    B2 = $2
echo -e "\t\tSize\tFile_name"
echo -e "\t\t=======\t==========="
ls -l > temp
tr -s " " < temp > temp2
count=0
while read line
do
    if [ $count -ne 0 ]
    then
        size = `echo $line | cut -d " " -f 5`
        fname = `echo $line | cut -d " " -f 9`
        if [ $size -le $B2 -a $size -ge $B1 ]
        then
            echo -e "\t\t$size\t$fname"
        fi
    fi
    count=1
done < temp2

No comments:

Post a Comment