Sei sulla pagina 1di 5

p 10 echo "Enter the String to Reverse" read string len=`echo $string |wc -c` len=`expr $len - 1` while [ $len

-ge 1 ] do c=`echo $string |cut -c $len` rev="$rev$c" len=`expr $len - 1` done echo "Reverse of the $string = $rev" p11 echo "Enter the value of n" read n ans=0 i=0 temp=0 i=1 while [ $i -le $n ] do temp=`echo "scale=4 ; 1/$i "|bc` ans=`echo "scale=4 ; $ans+$temp "|bc` i=`expr $i + 1` done echo "The value of series is $ans" p12 echo "Enter the String to Check" read string len=`echo $string |wc -c` len=`expr $len - 1` while [ $len -ge 1 ] do c=`echo $string |cut -c $len` rev="$rev$c" len=`expr $len - 1` done if [ "$string" = "$rev" ] then

echo "$string is Palindrome." else echo "$string is Not Palindrome." fi p14 n=0 while [ $n -ne 3 ] do echo echo "Enter your choice : " echo [1] File Process echo [2] Directory Process echo [3] Quit read n case $n in (1) n1=0 while [ $n1 -ne 5 ] do echo echo "Enter your choice : " echo [1] List Files echo [2] Make a File echo [3] Delete a File echo [4] Copy a File echo [5] Exit read n1 case $n1 in (1) echo "The list is as below " ls;; (2) echo "Enter the Name of File to create" read name echo "then Enter contents for File [To end press Ctrl+d]" cat >$name echo "File is created";; (3) echo "Enter Name of File to delete" read name rm $name;; (4)

echo "Enter Name of File to be Copied" read name echo "Enter Name of File to be updated:" read name1 cp $name $name1;; esac done;; (2) n2=0 while [ $n2 -ne 5 ] do echo echo "Enter your choice : " echo [1] Make Directory echo [2] Display Current Directory echo [3] Change Directory echo [4] Remove Directory echo [5] Exit read n2 case $n2 in (1) echo "Enter Name for new Directory" read name mkdir $name echo "Directory is successfully created.";; (2) echo "The Path to working Directory is " pwd;; (3) echo "Enter Name of Directory where to change" read name cd $name;; (4) echo "Enter Name of Directory to Delete" read name rmdir $name echo "Directory is Deleted";; esac done;; esac done p15

dir=`echo $home` cd $dir count=0 for i in `ls` do count=`expr $count + 1` done echo Total Number of Files in Home Directory : $count p16 echo "Enter the File Name in which Count process is to be done" read file c=`wc -c $file` w=`wc -w $file` l=`wc -l $file` echo "Character : $c" echo "Words : $w" echo "Lines : $l" p17 echo "Enter the Name of the File to be processed" read file tr '[A-Z]' '[a-z]' <$file >test1.txt p18 echo "Enter the File Name" read file echo "Enter Number of lines from top to be printed" read top echo "Enter Number of lines from bottom to be printed" read bottom echo "Top $top lines in file $file" head -n $top $file echo echo "Last $bottom lines in file $file" tail -n $bottom $file p19 echo "Enter the File Name to Process" read file

echo "Enter the Word to Search" read word echo "The lines that contains the word $word in file $file are below :" echo grep -i $word $file echo echo "The Total Number of Lines that contains the word $word is" grep -c $word $file p20 echo "Enter the File Name to Process" read file echo "Enter the Word to Search" read word i=`echo | grep -c $word $file` echo "The Occurrence of word $word in file $file is $i" p21 echo "Enter the Number of Students" read n `echo "" > list.txt ` while [ $n -ge 1 ] do echo "Enter Student Data" echo echo "Roll No. Name Marks" read rollno name marks input="$rollno|$name|$marks" `echo $input >> list.txt` n=`expr $n - 1` done echo echo "The Sorting result for Top five Students is as below :" echo sort -t"|" -r -n -k 3 list.txt > final.txt head -n 5 final.txt