I am new to Unix and need help with the following (to you all I'm sure) simple task. I am trying to output the differences between previous snaphots of various filesystem sizes to the present sizes.
I need a script to subtract the respective fields of file1 & file2, match this up with the respective fields in file3 and to output the result of this to standard output line by line.
i.e. Filesystem /var has changed by 90Kb
Filesystem /opt has changed by 180KB
Filesystem /tmp has changed by 270KB
I have tried :
#!/bin/ksh
for filesystem in `cat filesystems`
do
for curr_fs in `cat curr_fs_sizes`
do
for prev_fs in `cat prev_fs_sizes`
do
change=`expr ${curr_fs} - ${prev_fs}`
echo "Filesystem ${filesystem} has changed by ${change}Kb"
done
done
done