#!/bin/bash
You know what this is....
compare_file_sizes ()
Naming the function
{
Starting the function
# 2 variables below....
Just a comment
matchsize="633K"
Setting a variable
FILENAME="field.jpg"
Setting another variable
du -h0 ${FILENAME} > /tmp/comparefilesize.txt
du is "disk usage" the -h is for "human readable" and the 0 is for ending the line with a null instead of a newline character
filesize=`cut -f 1 /tmp/comparefilesize.txt`
setting filesize variable with a command. "cut" sorts through a text file... -f 1 means field one
rm -f /tmp/comparefilesize.txt
"rm" removes -f "forces removal" of the temp file
if [ "$filesize" == "$matchsize" ]
this is the start of the if/then statement the "==" means equal too
then
#do something
echo "file size is a match "
else
# do something
echo "file size is ${filesize} and does not match"
fi
ending the if/then statement
}
Ending the function
compare_file_sizes
This starts the function
exit
This exits the program