Programming Homework Help

King Abdulaziz University Awk Command in Text Processing Program

 

Q1- Using the awk utility, filter out the following output to solely show the size and mount point. Show all of your commands in a snapshot.

-bash-4.2$ df -h

Filesystem Size Used Avail Capacity Mounted on

/dev/wd0a 1008M 130M 828M 14% /

/dev/wd0d 1008M 8.6M 949M 1% /suid

/dev/wd0e 63.0G 29.8G 30.1G 50% /usr

/dev/wd0f 19.7G 16.0G 2.7G 85% /var

/dev/wd0g 3.9G 500K 3.7G 0% /tmp

Q2 Modify the script below using the following instructions. Show all of your commands and output in a snapshot.

a) Adjust the thresholds to get some results. Hint: lower the value of 99, 95, 90, etc. For example, the Docker login has 25% capacity of some directories.

b) Instead of the e-mail (like jdoe@comcast.net), echo a message into a file.

# Platform: Not Platform Dependent

#

space= df -k | awk ‘{print $5}’ | tr -d ‘%’

if [ ${space} -gt 99 ]

then mailx -s “Warning” jdoe@comcast.net

Disk space has reached 99%

elif [ ${space} -gt 95} ]

then mailx -s “Warning” jdoe@comcast.net

Disk space has reached 95%

elif [ ${space} -gt 90 ]

then mailx -s “Warning” jdoe@comcast.net

Disk space has reached 90%

else

echo “disk fine”

fi

Q3

You have a UNIX file named “food” with the following information. Show all of your commands and output in a snapshot.

cat food

The menu contains pork.

Using the sed command, change the pork to fish.