Professional Documents
Culture Documents
4. DIRECTORY COMMANDS
5. FILTER COMMANDS
9. PALINDROME
10 MULTIPLICATION TABLE
EX.NO: 1
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
echo "1.Make directory"
echo "8.Compare"
echo "10.Split"
echo "11.diff"
echo "12.Exit"
while ( true )
do
read choice
case $choice in
read name
mkdir $name ;;
read fname
vi $fname ;;
ls ;;
read rname
rm $rname ;;
read srname
read dtname
cp $srname $dtname ;;
6)echo "Displayfile"
read dispname
cat $dispname ;;
read mname
read desname
mv $mname $desname ;;
read file2
cmp $file1 $file2 ;;
read wcfile
wc $wcfile ;;
read splitname
read dif1
read dif2
12)echo "Exit"
exit ;;
esac
done
OUTPUT:
[masc@localhost akash]$ vi commands.bsh
1.Make directory
2.Create file
3.List file
4.Remove file
5.Copy file
6.Display file
7.Move file
8.Compare
9.Word count
10.Split
11.diff
12.Exit
it
List of files
a.txt
Enter a sourcefile
as.bsh
Displayfile
a.txt
expr 5 + 34
i=5
expr $i + 1
k= expr
Move file/rename
as.bsh
enter destination
a.txt
Enter a file1:
dummyfile.txt
Enter a file2:
cba.txt
cba.txt
2 4 26 cba.txt
10
a.txt
11
Enter a file1(differ)
dummyfile.txt
Enter a file2(differ)
cba.txt
1,3c1,2
< lkmlkm
< fdlkjldf\
< ndf,df,.mf
---
> im akash
12
Exit
[masc@localhost akash]$
EX.NO:2
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
echo "1.Logged User"
echo "8.Exit"
while(true)
do
read n
case $n in
1)whoami ;;
2)pwd ;;
3)uname -a ;;
4)who -u ;;
5)echo $SHELL ;;
6)ps -u;;
7)free ;;
8)exit;;
esac
done
OUTPUT:
[masc@localhost ~]$ ./prog2.bsh
1.Logged users
5.Available shells
6.CPU information
7.Memory information
8.Exit
masc
/home/mit
4
masc tty1 2000-12-31 19:09 old 1927 (:0)
/bin/bash
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME
COMMAND
masc 2620 0.0 0.1 5216 1684 pts/1 Ss+ 19:20 0:00 -bash
masc 3213 0.0 0.1 5216 1688 pts/6 Ss+ 20:58 0:00 -bash
masc 3401 0.0 0.1 5216 1676 pts/5 Ss 21:05 0:00 -bash
masc 3441 0.0 0.1 5216 1752 pts/7 Ss 21:08 0:00 -bash
masc 3605 0.0 0.1 5216 1684 pts/8 Ss 21:12 0:00 -bash
masc 3628 0.0 0.3 11048 3220 pts/8 S+ 21:12 0:00 vim commands.bsh
masc 3737 0.0 0.2 10776 2984 pts/5 S+ 21:15 0:00 vim
masc 3756 0.0 0.1 5216 1784 pts/2 Ss+ 21:16 0:00 -bash
masc 3827 0.0 0.1 5216 1688 pts/0 Ss 21:19 0:00 -bash
masc 3900 0.0 0.1 5216 1684 pts/3 Ss 21:21 0:00 -bash
masc 3944 0.0 0.3 10908 3236 pts/7 S+ 21:22 0:00 vim prg13.bsh
masc 3980 0.0 0.1 5216 1680 pts/4 Ss+ 21:23 0:00 -bash
masc 4081 0.0 0.0 5216 876 pts/0 S+ 21:23 0:00 -bash
masc 4082 0.0 0.0 5216 924 pts/3 S+ 21:23 0:00 -bash
masc 4093 0.1 0.1 5216 1680 pts/9 Ss+ 21:24 0:00 -bash
exit
EX.NO:3
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
echo "1.pipes"
echo "2.redirection"
echo "4.exit"
while(true)
do
read n
case $n in
ls
ls | head -3;;
ls ;;
4)exit
esac
done
OUTPUT:
[masc@localhost akash]$ chmod +x prog3.bsh
1.pipes
2.redirection
3.tee commands
4.exit
enter ur choice:
list of files
45
a.bsh
enter ur choice:
enter ur choice:
45
a.bsh
as.bsh
cba.txt
commands.bsh
dummyfile.txt
file1.txt
file2
g
gg
infotech
ingotech
mul.bsh
multable.bsh
new1
newaa
newab
newac
newad
newae
newaf
newag
newah
newai
newfile2.txt.txt
prg5.bsh
priya
priya.bsh
priya.txt
prog10.bsh
prog1.bsh
prog2.bsh
prog3.bsh
EX.NO:4
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
echo "1.date"
echo "4.exit"
while(true)
do
read n
case $n in
1)date;;
2)who;;
3)ls ;;
4)exit;;
esac
done
OUTPUT:
1.date
4.exit
4
EX.NO:5
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
echo "Filter Command"
echo "5.exit"
while(true)
do
read n
case $n in
read f
read s
grep $s $f ;;
read f
wc $f ;;
read word
read name
vi $name.txt
cat $name.txt
5)echo "exit"
exit ;;
esac
done
OUTPUT:
[masc@localhost akash]$ chmod +x prog5.bsh
Filter Command
1.Grep(matching pattern)
2.wc filter
3.cut filer
4.tr filter
5.exit
enter ur choice:
prog10.bsh
echo
enter ur choice:
prog10.bsh
10 29 120 prog10.bsh
enter ur choice:
3
wikipedia
enter ur choice:
newfile2.txt
Before Translation---
hi
this
is my
program
After Translation---
HI
THIS
IS MY
PROGRAM
enter ur choice: 5
exit
EX.NO:6
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
clear
read fname
if [ -s $fname ]
then
ls -l $fname
else
rm $fname
fi
OUTPUT:
[masc@localhost akash]$ chmod +x prog6.bsh
dummyfile.txt
dummy2.txt
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
echo -n "Enter the number:"
read n
sd=0
sum=0
while [ $n -gt 0 ]
do
sd=$(( $n % 10 ))
n=$(( $n / 10 ))
done
[masc@localhost akash]$
EX.NO:8
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
echo "enter the first number"
read first
read sec
read third
else
fi
else
else
fi
fi
OUTPUT:
[masc@localhost akash]$ chmod +x prog8.bsh
45
100
96
DATE:
AIM:
ALGORITHM:
PROGRAM CODING:
read str
echo $str>temp
res="$(rev temp)"
else
fi
OUTPUT:
[masc@localhost akash]$ chmod +x prog9.bsh
APPA
its a palindrome
INFOTECH
[masc@localhost akash]$
EX.NO:10
DATE:
AIM:
AL;GORITHMl:
PROGRAM CODING:
echo "Enter a number"
read n
i=1
while [ $i -le 10 ]
do
expr $n \* $i
let "i++"
done
OUTPUT:
masc@localhost akash]$ vi prog10.bsh
Enter a number
9X1=9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
9 X 6 = 54
9 X 7 = 63
9 X 8 = 72
9 X 9 = 81
9 X 10 = 90