630007 - Programming Skills-V (OS) [2/3]
Home >> mca  >> Sem 3 >> 630007 - Programming Skills-V (OS) [2/3]
11. Write a script to display the directory in the descending...
Shared By : Divya S Didwania (LCIT) Show/Hide Program  
11 Write a script to display the directory in the descending order of the size of each file. ************************************************************************************************************************************ echo -n "Enter directory name : " read dname  ls $dname > file  echo "No of files in directory : $(grep [^*$] file-c)" rm -f file  ls | sort -r find . -size +1000c -print   or echo Enter Directory read direc cd $direc  ls -Sl  ~ "111.sh" 5L, 51C written [divya@linux ~]$ sh 111.sh Enter Directory d1 total 28 drwxrwxr-x 3 divya divya 4096 2010-08-10 17:10 jk -rw-rw-r-- 1 divya divya   27 2010-09-18 16:36 second -rw-rw-r-- 1 divya divya   18 2010-10-04 11:50 first -rw-rw-r-- 1 divya divya    0 2010-09-27 16:17 file  ****************************************************************** 11. Write a script to display the directory in the descending order of the size of each     file.  echo Enter Directory read direc cd $direc  ls -Sl 12. Write a script to implement the following commands:...
Download link: http://www.megaupload.com/?d=8KKDFT1M 13. Write a script for generating a mark sheet after reading...
Download link: http://www.megaupload.com/?d=8KYUYPWN Shared By : Divya S Didwania (LCIT) Show/Hide Program  
13.  Write a script for generating a mark sheet after reading data from a file.  File contains student roll no, name , marks of three subjects.  ****************************************************************** count=1         total=0         per=0         rem1=0         wc -l s > temp         echo "************************************************************"         >>s.out         echo "            Students Result Are As Follows....."         >> s.out         echo "************************************************************"         >> s.out         echo "Rno NAME     SUB1   SUB2   SUB3 TOTAL PERCENTAGE GRADE  RESULT"          >> s.out         echo "************************************************************"         >> s.out         while [ $count -le `awk '{print $1}' temp` ]            do                 let total=0                 head -$count s > temp1                 tail -1 temp1 > temp2                 rollno=`awk '{print $1}' temp2`                 name=`awk '{print $2}' temp2`                 sub1=`awk '{print $3}' temp2`                 sub2=`awk '{print $4}' temp2`                 sub3=`awk '{print $5}' temp2`                 let total=$total+`awk '{print $3}' temp2`                 let total=$total+`awk '{print $4}' temp2`                 let total=$total+`awk '{print $5}' temp2`                 echo "STUDENT NAME IS :" `awk '{print $2}' temp2`                 echo "TOTAL IS :" $total                 let per=`expr $total / 3`                 let rem1=`expr $total % 3`                 if test $rem1 -ne 0                      then                         let per=$per+1                 fi                  echo "PERCENTAGE IS :" $per                    if [  $per -ge 70 ]                            then                               grade="A+"                    elif test $per -ge 60                         then                                   grade="A"                    elif test $per -ge 50                         then                                   grade="B"                   elif  test $per -ge 45                         then                                   grade="C"                     fi                   echo "GRADE IS :" $grade            let count=$count+1          #WRITING DATA INTO THE OUTPUT FILE           echo $rollno  $name "   " $sub1 "   " $sub2 "   " $sub3 "   " $total "     " $per "   " $grade   >> s.out     echo "-----------------------------------------------------"   >> s.out        done   rm temp   rm temp1   rm temp2  output [divya@linux ~]$ cat s 1 divya 40 30 70 2 Raj   60 40 90 [divya@linux ~]$ sh 131.sh ************************************************************             Students Result Are As Follows..... ************************************************************ Rno NAME     SUB1   SUB2   SUB3 TOTAL PERCENTAGE GRADE  RESULT ************************************************************ STUDENT NAME IS : divya TOTAL IS : 140 PERCENTAGE IS : 47 GRADE IS : C 1 divya     40     30     70     140      47     C ----------------------------------------------------- STUDENT NAME IS : Raj TOTAL IS : 190 PERCENTAGE IS : 64 GRADE IS : A 2 Raj     60     40     90     190      64     A -----------------------------------------------------                                                                   ****************************************************************** Shared By : Your Name (College - Place ) Show/Hide Program  
Share this program... Send it to gtumca@gmail.com with your Name - College name.. and share what you want ... at same mail id... Thanx in advance... Be connected... D_i_Z 14. Write a script to make following file and directory management...
Shared By : Rushyang Darji (SVIT -Vasad ) Show/Hide Program  
#!/usr/bin/env bash # Code written By: Rushyang Darji # Last Updated: 13.08.2010 # Visit My Online Repository: "http://github.com/rushyang/GTU-OS-Bash-Scripts" for regular updates and more scripts. : << --  14. Write a script to make following file and directory management operations menu based:     Display current directory     List directory     Make directory     Change directory     Copy a file     Rename a file     Delete a file     Edit a file --  while true; do   sleep 1 echo -e "\n" echo -e "    1. Display current directory     2. List directory     3. Make directory     4. Change directory     5. Copy a file     6. Rename a file     7. Delete a file     8. Edit a file     9. Exit     Enter your choice: \c" read selection clear  case $selection in   1) pwd ;;  2) ls -l ;;  3) echo -n "Enter name of directory you wanna make: " read DIR mkdir "$DIR" if [ "$?" == "0" ]; then     echo "Directory $DIR made successfully!"     sleep 1     ls -l fi ;;  4) echo -n "Enter the Absolute Path to change the directory: " read -e apath cd $apath     if [ $? -eq 0 ]; then          echo "Working path changed successfully!"         sleep 1         pwd     fi ;;  5) echo -n "Enter name of file: " read filename echo -n "Copy where? " read -e apath cp $filename $apath  if [ $? -eq 0 ]; then     sleep 1     echo "File $filename copied successfully to $apath" fi ;;  6) echo -n "Enter old name of the file: " read oname echo -n "Enter new name: " read nname mv $oname $nname ;;  7) echo -n "Enter filename to delete: " read fdel if [ -f $fdel ]; then     rm -i $fdel fi ;;  8) echo -n "Enter filename to open it in Text Editor: " read filename vi $filename ;;  9)  clear echo "============ HAVE A NICE DAY ============" sleep 2  clear exit ;;  *) echo "Invalid choice, Please try again!: " ;;  esac done  Shared By : Divya S Didwania (LCIT) Show/Hide Program  
14 Write a script to make following file and directory management operations menu based:  ****************************************************************** Display current directory List directory Make directory Change directory Copy a file Rename a file Delete a file Edit a file ****************************************************************** clear choice=y while [ "$choice" = "y" ] do  echo "          MAIN MENU       " echo "***************************" echo "1 - DISPLAY CURRENT DIRECTORY" echo "2 - LIST DIRECTORY" echo "3 - MAKE DIRECTORY" echo "4 - CHANGE DIRECTORY" echo "5 - COPY A FILE" echo "6 - RENAME A FILE" echo "7 - DELETE A FILE" echo "8 - EDIT A FILE" echo "9 - EXIT"  echo "ENTER THE CHOICE :- " read choice case $choice in  1) echo "DISPLAYING CURRENT DIRECTORY"    pwd     ;;  2) echo "\nLIST THE CURRENT DIRECTORY"    ls -l    read     ;;  3) echo "\nMAKE A NEW DIRECTORY"    echo "\nENTER THE DIRECTORY NAME :-\c"    read dirname    mkdir "$dirname"    read dirname      ;;  4) echo "\nCHANGE THE CURRENT DIRECTORY"    echo "\nENTER THE DIRECTORY TO WHICH YOU WANT TO    read dirname   pwd    cd ..     ;;  5) echo "\nCOPY THE GIVEN FILE TO THE GIVEN DESTINAT    echo "\nENTER THE FILE TO COPY :- \c"    read file    echo "\nENTER THE DESTINATION TO COPY :- \c"    read destin    cp "$file" "$destin"     ;;  6) echo "\nRENAMING THE GIVEN FILE"    echo "\nENTER THE FILE TO RENAME :- \c"    read file1    echo "\nENTER THE NEW NAME :- \c"    read file2    mv "$file1" "$file2"      ;;  7) echo "\nDELETING THE GIVEN FILE"    echo "\nENTER THE FILE TO DELETE :- \c"    read file    rm "$file"     ;;  8) echo "\nEDITING A GIVEN FILE"    echo "\nENTER FILE TO EDIT :- \c"    read file    vi "$file"    :q      ;;  9) exit     ;;  *) echo "Invalid Choice ....."  ;;  esac  echo -e "Do u want to continue.....? [y/n]"  read choice  case $choice in   Y|y) choice=y;;   N|n) choice=n;;   *) choice=y;;  esac done   output           MAIN MENU *************************** 1 - DISPLAY CURRENT DIRECTORY 2 - LIST DIRECTORY 3 - MAKE DIRECTORY 4 - CHANGE DIRECTORY 5 - COPY A FILE 6 - RENAME A FILE 7 - DELETE A FILE 8 - EDIT A FILE 9 - EXIT ENTER THE CHOICE :- 1 DISPLAYING CURRENT DIRECTORY /home/Raj [Divya@linux ~]$ ENTER THE CHOICE :- 2 \nLIST THE CURRENT DIRECTORY total 96 -rw-rw-r-- 1 Raj Raj 1590 2010-07-26 16:27 14.sh -rw-rw-r-- 1 Raj Raj   21 2010-07-26 16:33 d drwxrwxr-x 2 Raj Raj 4096 2010-07-26 16:28 divya drwxrwxr-x 4 Raj Raj 4096 2010-07-26 16:22 family -rw-rw-r-- 1 Raj Raj  232 2010-07-23 16:39 fib.sh -rw-rw-r-- 1 Raj Raj  171 2010-07-26 16:52 log.sh -rw-rw-r-- 1 Raj Raj    9 2010-07-26 16:15 palin -rw-rw-r-- 1 Raj Raj  288 2010-07-26 16:48 pal.sh -rw-rw-r-- 1 Raj Raj  167 2010-07-26 14:19 pm.sh drwxrwxr-x 3 Raj Raj 4096 2010-07-24 16:38 r -rw-rw-r-- 1 Raj Raj  304 2010-07-26 16:55 time.sh -rw-rw-r-- 1 Raj Raj  264 2010-07-24 16:29 zero.sh ENTER THE CHOICE :- 3 \nMAKE A NEW DIRECTORY \nENTER THE DIRECTORY NAME :-\c divya1  [Divya@linux ~]$ ls 14.sh  divya   family  log.sh  pal.sh  r        zero.sh d      divya1  fib.sh  palin   pm.sh   time.sh ENTER THE CHOICE :- 5 \nCOPY THE GIVEN FILE TO THE GIVEN DESTINATION \nENTER THE FILE TO COPY :- \c d \nENTER THE DESTINATION TO COPY :- \c t  [Divya@linux ~]$ cat t target +destinatyion  ENTER THE CHOICE :- 6 \nRENAMING THE GIVEN FILE \nENTER THE FILE TO RENAME :- \c d \nENTER THE NEW NAME :- \c dest [Divya@linux ~]$ ls 14.sh  divya   family  log.sh  pal.sh  r  time.sh dest   divya1  fib.sh  palin   pm.sh   t  zero.sh ENTER THE CHOICE :- 7 \nDELETING THE GIVEN FILE \nENTER THE FILE TO DELETE :- \c t [Divya@linux ~]$ ls 14.sh  divya   family  log.sh  pal.sh  r        zero.sh dest   divya1  fib.sh  palin   pm.sh   time.sh  ENTER THE CHOICE :- 8 \nEDITING A GIVEN FILE \nENTER FILE TO EDIT :- \c dest  target +destinatyion rr Insert mode and save  [Divya@linux ~]$ cat dest target +destinatyion rr ****************************************************************** Shared By : Rajendra Rajani (SSIT-Gandinagar) Show/Hide Program  
*************************************************************************************************  pro14. Write a shell script to make the following file and management operations menu based:  a)  Display the current directory.  b)  List directory.  c)  Make directory.  d)  Change directory.  e)  Copy of a file.  f)   Rename a file.  g)  Delete a file.  h)  Edit a file.   ************************************************************************************************* choice=y while [ "$choice" = "y" ] do  echo -e "                       MENU                    "  echo -e "1. Display the current directory"  echo -e "2. List directory"  echo -e "3. Make directory"  echo -e "4. Change directory"  echo -e "5. Copy of a file"  echo -e "6. Rename a file"  echo -e "7. Delete a file"  echo -e "8. Edit a file"  echo -e "9. Exit"  echo "\n Enter your Choice :- "  read choice  case "$choice" in   1) pwd;;   2) ls;;   3) echo -e "enter the name of new directory to be created"           read dir1           mkdir $dir1;;   4) cd;;   5) echo -e "enter the source and destination files"           read f1           read f2           cp $f1 $f2;;   6) echo -e "enter the old and new names of files"           read f1            read f2           mv $f1 $f2;;   7) echo -e "which file to be removed"           read fname           rm $fname;;   8) echo -e "which file should be edited"           read fname           vi $fname;;   9) exit;;  esac  echo -e "Do u want to continue.....? [y/n]"  read choice  case $choice in   Y|y) choice=y;;   N|n) choice=n;;   *) choice=y;;  esac done /* 14. Write a script to make following file and directory management operations menu based: Display current directory List directory Make directory Change directory Copy a file Rename a file Delete a file Edit a file */ echo " 1...Display current Directory" echo " 2...List Directory" echo " 3...Make directory " echo " 4...Change directory " echo " 5...Copy a file " echo " 6...Rename a fIle " echo " 7...Delete a file " echo " 8...Edit a file "  echo " Enter Your Choice: " read ch  case $ch in         1)                 pwd                 ;;         2)                 ls                 ;;         3)                 echo Enter directory name to make                 read dir_name                 mkdir $dir_name                 ;;         4)                 cd                 ;;         5)                 echo Enter two file name to copy                 read f_name1 f_name2                 cp $f_name1 $f_name2                 ;;         6)                 echo Enter file name to rename                 read fname                 mv $fname                 ;;         7)                 echo Enter file name to delete                 read fname                 rm $fname                 ;;         8)                 echo Enter file name to edit                 read fname                 vi $fname                 ;;         *)                 echo You hv entered wrong choice                 ;; esac 15. Write a script which reads a text file and output the following...
Shared By : Divya S Didwania (LCIT) Show/Hide Program  
15.Write a script which reads a text file and output the following Count of character, words and lines. File in reverse. Frequency of particular word in the file. Lower case letter in place of upper case letter. ******************************************************************  echo -e "\n Enter Filename : " read filen echo "--------------------------------------------------------------" echo "                             MENU  " echo "--------------------------------------------------------------" echo " a) Count the no. of char.s, words, lines." echo " b) Display a file in reverse." echo " c) Count the no. of occurrences of a particular word." echo " d) Convert Lower case to UppeCase" echo "--------------------------------------------------------------" echo -e "\n Enter Your Choice : " read c case "$c" in         a) echo -e "\n Total lines,words,char.s " ; wc $filen ;;         b) rev $filen            read buf;;         c) echo -e "\nEnter word to find :"            read w            for i in `cat $filen`            do                 echo $i >> f1.txt            done            echo -e "Total no. of words= \c" ;grep -c $w f1.txt            grep $w f1.txt            rm f1.txt;;         *) echo "Invalid choice"  esac  ~ ~ "15.sh" 28L, 894C written [divya@linux ~]$ sh 15.sh   Enter Filename : s  --------------------------------------------------------------                              MENU --------------------------------------------------------------  a) Count the no. of char.s, words, lines.  b) Display a file in reverse.  c) Count the no. of occurrences of a particular word. d) Convert Lower case to UppeCase --------------------------------------------------------------   Enter Your Choice : a   Total lines,words,char.s   7  22 193 s [divya@linux ~]$ sh 15.sh   Enter Filename : b --------------------------------------------------------------                              MENU --------------------------------------------------------------  a) Count the no. of char.s, words, lines.  b) Display a file in reverse.  c) Count the no. of occurrences of a particular word. d) Convert Lower case to UppeCase --------------------------------------------------------------   Enter Your Choice : b rev: b: No such file or directory  [5]+  Stopped                 sh 15.sh [divya@linux ~]$ sh 15.sh   Enter Filename : s --------------------------------------------------------------                              MENU --------------------------------------------------------------  a) Count the no. of char.s, words, lines.  b) Display a file in reverse.  c) Count the no. of occurrences of a particular word.  d) Convert Lower case to UppeCase" --------------------------------------------------------------  Enter Your Choice : b  akram        eman       on llor 05    ilahsiav              1 04       jariv              2 05       lanos              3 03       layap              4 04       lahen              5 06 layap 6 [6]+  Stopped                 sh 15.sh [divya@linux ~]$ sh 15.sh   Enter Filename : s --------------------------------------------------------------                              MENU --------------------------------------------------------------  a) Count the no. of char.s, words, lines.  b) Display a file in reverse.  c) Count the no. of occurrences of a particular word. d) Convert Lower case to UppeCase --------------------------------------------------------------   Enter Your Choice : c  Enter word to find : payal Total no. of words= 2 payal payal [divya@linux ~]$ sh 15.sh   Enter Filename : s --------------------------------------------------------------                              MENU --------------------------------------------------------------  a) Count the no. of char.s, words, lines.  b) Display a file in reverse.  c) Count the no. of occurrences of a particular word.  d) Convert Lower case to UppeCase --------------------------------------------------------------   Enter Your Choice : d ROLL NO       NAME        MARKs 1              VAISHALI           50 2              VIRAJ                  40 3              SONAL               50 4              PAYAL                 30 5              NEHAL                40 6              PAYAL                    60  [divya@linux ~]$  *************************************************************** ************************************************************************************************ pro15. Write a script which reads a text file and output the following:  I)   Count of characters, words, lines.  II)  File in reverse."  III) Frequency of particular word in the file.   IV)  Lower case letters in place of uppercase alphabets. ************************************************************************************************ echo -e "\n Enter Filename : \c" read filen echo "--------------------------------------------------------------" echo "                             MENU  " echo "--------------------------------------------------------------" echo " a) Count of characters, words, lines." echo " b) File in reverse." echo " c) Frequency of particular word in the file.word." echo " d) Lower case letters in place of uppercase alphabets." echo "--------------------------------------------------------------" echo -e "\n Enter Your Choice : \c" read c case "$c" in  a) echo -e "\n Total lines,words,char.s \c" ; wc $filen ;;  b) rev $filen     read buf;;  c) echo -e "\nEnter word to find : \c"     read w     for i in `cat $filen`            do                 echo $i >> f1.txt            done            echo -e "Total no. of words= \c" ;grep -c $w f1.txt            grep $w f1.txt            rm f1.txt ;;  d) echo "Enter the text (Enter ctrl+D for end>:"     cat > temp.txt     echo "See temp.txt file for output..."     tr [a-z] [A-Z] <>Shared By : Hetal Modi (College - CTI - Gandhinagar ) Show/Hide Program  
15. Write a script which reads a text file and output the following     Count of character, words and lines.     File in reverse.     Frequency of particular word in the file.     Lower case letter in place of upper case letter.  echo "Enter File Name" read fname echo "       1...Count character,words and lines       2...Reverse File       3...Found frequency of word       4...Convert upper to lower       5...Convert lower to upper       ------------------------------------" echo "Enter Choice: " read ch case $ch in 1)         echo Total Character:         wc -c $fname         echo Total Words:         wc -w $fname         echo Total Lines:         wc -l $fname         ;; 2)         rev $fname         ;; 3)         echo Enter word to find        read w         echo Frequency:         grep  -c "$w" $fname         ;; 4)         echo Enter Text         read text         echo $text | tr "[A-Z]" "[a-z]"         ;; 5)         echo Enter Text         read text         echo $text | tr "[a-z]" "[A-Z]"         ;; *)         echo Wrong Choice         ;; esac   /* output [mca0914@ctilinux-1 mca0914]$ sh 15.sh Enter File Name abc.txt        1...Count character,words and lines       2...Reverse File       3...Found frequency of word       4...Convert upper to lower       5...Convert lower to upper       6...-------------------------------- Enter Choice: 1 Total Character:      15 abc.txt Total Words:       4 abc.txt Total Lines:       2 abc.txt ****************************************************** Enter Choice: 2 olleH ?u r woH ****************************************************** Enter Choice: 3 Frequency: 2 ****************************************************** Enter Choice: 4 Enter Text HET het ****************************************************** Enter Choice: 5 Enter Text het HET ******************************************************  16. Write a shell script to check whether the named user is...
#!/usr/bin/env bash # Code written By: Rushyang Darji # My Online Repository: http://github.com/rushyang/GTU-OS-Bash-Scriptss : << -- This shell script will verify whether the user is logged in or not. --  echo -e "Enter username to verify whether he is logged in or not: \c" read myname  who | awk '{print $1}' > allusers_dummy.log sed -n /^$myname$/p allusers_dummy.log > finalusers_dummy.log SIZE=`ls -s finalusers_dummy.log | awk '{ print $1 }'`  if [ $SIZE -eq 0 ]; then     echo "User is not logged in" else     echo "User: $myname is currently logged in"     sleep 2     who | sed -n /^$myname/p  fi  rm allusers_dummy.log rm finalusers_dummy.log  # OR  #!/usr/bin/env bash # Code written By: Rushyang Darji # My Online Repository: http://github.com/rushyang/GTU-OS-Bash-Scripts  echo -e "Enter name of user: \c" read myname   finaluser=`who | awk '{print $1}' | sed -n /^$myname$/p | head -n1` if [ "$myname" = "$finaluser" ]; then     echo "User is currently logged in."     sleep 1     who | sed -n /^$myname/p  else     echo "User is not currently logged in. " fi    Shared By : Divya S Didwania (LCIT) Show/Hide Program  
16.Write a shell script to check whether the named user is currently logged in or not ****************************************************************************************  clear echo -e "Enter The User name : " read name   (who | grep $name  ) && clear  echo "The User " $name && echo " Is Currently Logged In " || echo "is logged out"  ~ ~ ~ ~ ~ ~ ~ ~ Output Enter The User name : Raj  The User  Raj  Is Currently Logged In [Divya@linux ~]$  ************************************************************* Shared By : kuldeep (SSIT) Show/Hide Program  
kuldeep-SSIT  ************************************************************************************************  10. To Find That Given User is Currently Logged In Or Not.  ************************************************************************************************  clear echo "Enter The User name :\c " read name  >>temp echo "The User \c " $name  (who | grep $name >> temp ) && echo " Is Currently Logged In " || echo "is not logged in"            ************************************************************************************************ OR ****  #message Broadcast for a Single User,Multiple Users and to All#   who > e.txt  echo "For Broadcasting Messages."  if [ $# = 0 ] then     echo "Enter the User Name:\c"         read nam         p=`grep $nam e.txt`              if [ "$p" != "" ]     then             write $nam             rm e.txt             exit         else                echo "The user is not logged in"         fi              rm e.txt         exit                                    fi  if [ "$1" = "all" ] then     wall fi   for nam in $* do     p=`grep $nam e.txt`             if [ "$p" != "" ]        then                write $nam        else                echo "The User $nam is not logged in"        fi done                        ************************************************************************************************  #OR ****  echo "enter user name"  read n  who | grep "^$n"  if [ $? -eq 0 ] then     echo "currently log in" else     echo "not log in" fi  ************************************************************************************************  17. Write a Script for Simple Database Management System...
Shared By : Your Name (College - Place ) Show/Hide Program  
Share this program... Send it to gtumca@gmail.com with your Name - College name.. and share what you want ... at same mail id... Thanx in advance... Be connected... D_i_Z 18. Write A Script To Perform Following String Operations...
Shared By : Hetal Modi  ( CTI - Gandhinagar ) Show/Hide Program  
/*18. Write A Script To Perform Following String Operations Using Menu: COMPARE TWO STRINGS. JOIN TWO STRINGS. FIND THE LENGTH OF A GIVEN STRING. OCCURRENCE OF CHARACTER AND WORDS E. REVERSE THE STRING. */  while true do echo --------------------------------------- echo 1...COMPARE TWO STRINGS echo 2...JOIN TWO STRINGS echo 3...FIND THE LENGTH OF A GIVEN STRING echo 4...OCCURRENCE OF CHARACTER AND WORDS echo 5...REVERSE THE STRING echo --------------------------------------- echo Enter Choice: read ch echo ---------------------------------------  case $ch in  1)         echo Enter String1:         read str1         echo Enter String2:         read str2          if [ $str1 = $str2 ]         then                 echo String is equal         else                 echo String is not equal         fi         ;; 2)         echo Enter String1:         read str1         echo Enter String2:         read str2          str3=$str1$str2         echo Join String: $str3         ;; 3)         length=0         echo Enter String1:         read str1         length=`expr $str1 | wc -c`         length=`expr $length - 1`         echo Length: $length         ;; 4)         echo Enter String:         read str          echo Enter Word to find         read word          echo $str | cat > str1.txt          grep -o $word str1.txt | cat > str2.txt         count=`grep -c $word str2.txt`      echo Count: $count     ;; 5)         echo Enter String1:         read str          len=`expr $str | wc -c`         len=`expr $len - 1`         while [ $len -gt 0 ]         do                 rev=`expr $str | cut -c $len`                 ans=$ans$rev                 len=`expr $len - 1`         done         echo Reverse String: $ans         ;;  *)         echo Wrong Choice         ;; esac         echo Do u want to continue?     read ans     if [ $ans = n ]     then         exit     fi done  19. Write a script to calculate gross salary for any number...
Shared By : Your Name (College - Place ) Show/Hide Program  
Share this program... Send it to gtumca@gmail.com with your Name - College name.. and share what you want ... at same mail id... Thanx in advance... Be connected... D_i_Z 20. Write a script to check whether a given string...
Shared By : Hetal Modi  ( CTI - Gandhinagar ) Show/Hide Program  
/*     20. Write a script to check whether a given string is palindrome or not. */ echo Enter String read str      length=0     cnt=1     flag=0  length=`expr $str | wc -c` length=`expr $length - 1` temp=`expr $length / 2`  while test $cnt -le $temp do         rev=`expr $str | cut -c $cnt`         ans=`expr $str | cut -c $length`          if [ $rev != $ans ]         then                 flag=1         fi          cnt=`expr $cnt + 1`         length=`expr $length - 1` done  if [ $flag -eq 0 ] then         echo String is palindrome else         echo String is not palindrome fi 

0 comments:
Post a Comment