Solutions For Assignment 2
Solutions For Assignment 2
if test f $1
then
echo file exists
else
echo file does not exist
fi
if test $# -ne 1
echo you must give an argument
else
elif test f $1 o d $1
then
echo file exists
else
echo file does not exist
fi
if test $# -ne 1
echo you must give an argument
elif test f $1
then
echo file exists
mv $1 /usr/$1
echo File moved
else
echo file does not exist
fi
today=`date`
result=`grep $today $1`
if [ "result" ]
then
echo "The file $1 was created today"
else
echo "The file $1 was not created today"
fi
#!/bin/sh
# Start at month 1
month=1
while [ $month -le 12 ]
do
echo "Month no. $month"
month=`expr $month + 1`
done
#!/bin/sh
password="open"
answer=""
while [ "forever" ]
do
echo "Guess the password to quit the program> \c"
read answer
if [ "$answer" = "$password" ]
then
break
fi
done
Part A
1. date | cut d f 1,2,3,4,5,6 output-delimiter=$\n or date|tr [:space:] \n
2. paste d -s date.lst
3. tail +11 /etc/passwd
4. sort t : k 3,3 -k4,4 /etc/passwd
5. ls lS | head -5 [s based on file size in blocks
S based on file size in bytes ]
6. tail +5 /etc/passwd |head -5
Part B