Monday, April 3, 2017

Bash: Scripting - part 1 - File Info

#!/bin/bash
#
#  fileinfo.sh
MYFILES="/auto/home/homeb/d54712/sandbox/scripts/bash.d/read1.sh
/auto/home/homeb/d54712/sandbox/scripts/data.d/states
/auto/home/homeb/d54712/sandbox/scripts/data.d/states12345"     # List of files you are curious about
                                                                #Threw in in a dummy file, /auto/home/homeb/d54712/sandbox/scripts/bash.d/states12345



#
echo
for file in $MYFILES
do
        if [ ! -e "$file" ]
        then
                echo "$file does not exist."
                continue
        fi
        ls -l $file |awk '{ print $8 "          file size: " $5 }' # print 3 fields
        echo
done
exit 0






Results:

$ ./fileinfo.sh
14:23           file size: 126
15:30           file size: 78
/auto/home/homeb/d54712/sandbox/scripts/data.d/states12345 does not exist.

No comments:

Post a Comment