Programs
Programs
Programs
awk -F “|” ‘{ printf “%4d %20s %2d %2d %2d %3d %3.2d \n”, NR, $1,$2,$4,$5,$6,$4+$5+$6,($4+$5+
$6)/7 }’ mark
awk -F “|” ‘{printf “%4d %20s %2d %2d %2d %3d %3.2d \n”,
$1,$2,$4,$5,$6,$4+$5+$6,($4+$5+$6)/7 }’ mark
awk -F “|” ‘{printf “%4d %-20s %2d %2d %2d %3d %3.2d \n”,
$1,$2,$4,$5,$6,$4+$5+$6,($4+$5+$6)/7 }’ mark
awk -F “|” ‘$1>2000 {printf “%4d %-20s %2d %2d %2d %3d %3.2d \n”, $1,$2,$4,$5,$6,$4+$5+$6,($4+
$5+$6)/7 }’ mark
awk -F “|” ‘BEGIN {print "Marklist"} $1>2000 {printf “%4d %20s %2d %2d %2d %3d %3.2d \n”,
$1,$2,$4,$5,$6,$4+$5+$6,($4+$5+$6)/7 }’ mark
awk -F “|” ‘BEGIN {print "Marklist"} $1>2000 {printf “%4d %20s %2d %2d %2d %3d %3.2d \n”,
$1,$2,$4,$5,$6,$4+$5+$6,($4+$5+$6)/7} END {print "the end"}’ mark
awk -F “|” ‘BEGIN {print "Marklist"} $1>2000 {c++;printf “%d %4d %20s %2d %2d %2d %3d %3.2d \
n”,c,$1,$2,$4,$5,$6,$4+$5+$6,($4+$5+$6)/7} END {print "the end"}’ mark
awk -F “|” ‘BEGIN {print "Marklist"} $1>2000 {c=c+1;printf “%d %4d %20s %2d %2d %2d %3d %3.2d \
n”,c,$1,$2,$4,$5,$6,$4+$5+$6,($4+$5+$6)/7} END {print "the end";printf "Total records:%d\n",c}’
mark
Script to create simple menus and take action according to that selected
# menu item
#
while :
do
clear
echo "-------------------------------------"
echo " Main Menu "
echo "-------------------------------------"
echo "[1] Show Todays date/time"
echo "[2] Show files in current directory"
echo "[3] Show calendar"
echo "[4] Start editor to write letters"
echo "[5] Exit/Stop"
echo "======================="
echo -n "Enter your menu choice [1-5]: "
read yourch
case $yourch in
1) echo "Today is `date` , press a key. . ." ; read ;;
2) echo "Files in `pwd`" ; ls -l ; echo "Press a key. . ." ; read ;;
3) cal ; echo "Press a key. . ." ; read ;;
4) vi ;;
5) exit 0 ;;
*) echo "Opps!!! Please select choice 1,2,3,4, or 5";
echo "Press a key. . ." ; read ;;
esac
done
BEGIN {OFS="|"}
print $NF
Runawk -f lw.awk a1
write a shell script that will read two numbers from command line and display all even numbers
between two numbers.
echo $1
echo $2
n1=$1
n2=$2
while test $n1 -lt $n2
do
test=$(( $n1 % 2 ))
then
echo $n1
fi
n1=`expr $n1 + 1`
done
Runsh a1.sh 1 10
clear
choice=y
do
echo "____________________________________________"
echo "____________________________________________"
read ch
echo "____________________________________________"
case $ch in
1)
read str1
read str2
then
else
fi
;;
2)
read str1
read str2
str3=`echo $str1$str2`
echo $str3
;;
3)
len=0
read str1
len=`expr $len - 1`
;;
4)
read str
read word
echo $count
;;
5)
read str
len=`expr $str | wc -c`
len=`expr $len - 1`
do
ans=`expr $ans$rev`
len=`expr $len - 1`
done
echo $ans
;;
6) exit ;;
esac
read choice
case $choice in
Y|y) choice=y;;
N|n) choice=n;;
*) choice=y;;
esac
done
Write a shell script to display hour in time in word.
clear
h=`date +%H`
m=`date +%M`
s=`date +%S`
case $h in
Esac
Write a Shell Script to delete the zero sized file using if and for.
clear
read filenm
if [ -e $filenm ]
then
if [ -s $filenm ]
then
else
rm $filenm
fi
else
fi
i="y"
while [ $i = "y" ]
do
read choice
case $choice in
read choice;;
read g1
read choice;;
3)who | more
read choice;;
4) exit;;
esac
read i
if [ $i != "y" ]
then
exit
fi
done
Write a script to display the name of those files (in the given directory)
which are having multiple links
read dirpath