Ok, my name is Paul and i am new to this forum. I need some help and thought i can try my luck here. I need to write a program to do the following:

1. Need to write a shell script called fileutils.sh that will do:

Accept one variable on the command line and use the information stored in the variable in the script. Once inside the script the argument shold be given meaningful name and not reffered as $1
The single command line argument is the name of a log file to track the actions of the user during the life of the program must be used : ./fileutils myfile.log

Every time the user makes a menu selection, the selection made, along with the date/time of making the selection, should be sent to the log file(myfile.log)

2. print the following menu on the screen and perform the required operations dictated by the menu item:

1.make a new directory
2.list out the contents of a file.
3.safely delete a file
4.produce statistical information using an ‘awk script’
5.display the full name of any user.
6.display the log file.
0.exit the program

3.the menu must be repeated for the user once an option has been completed so that they may choose another option.

1 – make a new directory (mkdir.sh) should include
-read in directory name
-check if it exists
-if it does, warn the user
-otherwise create it

2 – list out the contents of a file(list,sh) should include
-read file name
-check if it exists and s a file
-list contents

3 –safely delete a file(safedel.sh)should include
-the file can be recovered if the deletion was a mistake

4 –run an awk script (I am going to start this part bit later, we just started awk programming)

5 –display the full name of any user (display.sh) should include
-read in the login name
-find this in /etc/passwd
-display the login name and full user name only using cut and determine whether the user is logged in
-print a message uf the user does not exist

6 –display the log file

0 –exit the program


#Setup logging
echo "--------------------------------" >> $log
date >> $log

while [ $keeploop = 1 ]

#Print the menu
echo ""
echo "1 - Make a new directory"
echo "2 - List contents of a file"
echo "3 - Delete a file "
echo "4 - Produce Statistics"
echo "5 - Display name of User"
echo "6 - Display Log file"
echo "0 - Exit"
echo ""

read choice
echo ""
echo "Operator chose $choice" >> $log
echo ""

case "$choice" in

# Make a new directory
echo "Name of directory you wish to create?"
read newdir
echo ""
echo "Creating $newdir"
echo ""
mkdir $newdir
ls -dl $newdir
echo ""

# cat a fiile
echo "Name of file you wish to print to screen?"
read catfile
echo "--------------------------------------------------------"
cat $catfile
echo "--------------------------------------------------------"

# Delete a file

# Statistics

# User information

# log file

echo "Exiting"
echo "Exiting at" >> $log
date >> $log



Ok, so far i managed to get to this step. I am unsure how to perform step number 5/6. I should be able to finish step 3 with a success. Can you guys help me out a little? Much appreciated.

10 Years
Discussion Span
Last Post by eggi

Anyone? I need to get this done in next 3 weeks, any tips maybe?

Thank you.


Hey There,

For step 5, ask for user input like in your other steps and then use that information and run "finger" or grep out of /etc/passwd and format as you like.

For step 6 - just use cat - I don't know which system log you'd be looking for - /var/adm/messages, /var/log/syslog, etc

That should be all you need to do :)

, Mike

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.