01.12.09 - 05.08.09
Introduction to UNIX/Linux
Tuesday Thursday
08:30 AM - 09:50 AM
Shell script entered correctly | 15 pts |
Shell script made executable | 5 pts |
Total | 20 pts |
Use vi to create a shell script called wherearethey in your bin directory by entering the following script:
echo -n "Who are you looking for: " read user if [ -n "$user" ] then list=`w | grep $user | cut -c19-30` if [ "$list" != "" ] then echo "The user $user is logged in from $list" else echo "The user $user is not logged in now" fi fi
Make the script executable and run the script. Make an attempt to understand what the script is doing and how it is doing it.