Subject Code: 630007 (2a) Accept numbers and perform addition, subtraction, diision and multiplication echo !enter the alues a ::! read a echo !enter the alues of b:! read b echo !"#$ %A&U$ '( A::! )a echo !"#$ %A&U$ '( *::! )b echo !A++I"I'N '( :: , e-pr )a . )b ,! echo !SU*"/$C"I'N ::! , e-pr )a 01 )b , echo !2U&"I3&ICA"I'N::!, e-pr )a 04 )b , echo !+I%ISI'N '( ::! , echo )a 5 )b 6bc 1l , echo !2'+UA& ::! , echo )a 7 )b 6bc, (2b) Accept the strin8 and chec9s :hether the strin8 is palindrome or not; echo !$nter a Strin8! read str len<,echo )str 6:c 1c, i<= i<)len :hile > )i 18t ? @ do -<,echo )str 6cut 1c)i1)i, temp<)temp!!)- i<,e-pr )i 1 =, done echo )temp if > )str < )temp @ then echo !pallindrom;;AA! else echo !Not 3allindrom;;AA! B = *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script (2c) Accept number and chec9 the number is een or odd, Bnds the len8th of the number, sum of the di8its in the number; echo !Dien number is een or odd! echo !$nter a Number! read no clear temp<,e-pr )no 7 2, if > )temp 1eE ? @ then echo )no! is een! else echo )no !is 'dd! B len<,echo )no 6:c 1c, len<,e-pr )len 1 =, echo !&en8th of numbar is !)len sum<? rem<? :hile > )no 18t ? @ do rem<,e-pr )no 7 =?, sum<,e-pr )sum . )rem, no<,e-pr )no 5 =?, done echo !Sum of all di8its is:! )sum (2d) Accept strin8s and replace a strin8 bC another strin8; echo 1n !$nter Strin8: ! read str echo !Four strin8 is :! )str echo 1n !$nter :ord that Cou :ant to replace :ith other :ord: ! read oldstr echo 1n !$nter ne: :ord: ! read ne:str str<,echo )str 6 sed s5)oldstr5)ne:str58, 2 *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script echo !After /eplacin8: ! )str (2e) Accept Blename and displaCs last modiBcation time if Ble e-ists, other:ise displaC appropriate messa8e; echo !$nter (ile Name! read fnmae if > 1f )fname @ then echo !(ile $-ist! Gecho ,ls 1l 1t 68rep )fname 6cut 1fH 1d I I, else echo !(ile does not e-ist;;AA! B Gls 1l 1t 68rep J;sh 6cut 1fH 1d I I Gls 1l 1t 68rep J;sh 6cut 1fH 1d I I (2f) (etch the data from a Ble and displaC data into another Ble in reerse order echo !(etch data from another Ble! ls 1a echo !$nter (ile Name! read fName re )fName K temp cat temp (L) Mrite a script to Bnd the 8lobal complete path for anC Ble; echo !+isplaC Dlobal path for a Ble! echo !$nter Ble name! read fName echo )fName echo ,p:d, L *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script (N) Mrite a script to broadcast a messa8e to a speciBed user or a 8roup of users lo88ed on anC terminal echo !$nter user Name! read uName user<,:ho 6 8rep 1c )uName, if > )user 18t ? @ then echo )user :rite )uName else echo !0n*rodcast messa8e to all lo88in users! echo !0n$nter Cour messa8e! echo !0n>$nter ctrl . d to stop@! :all B (O) Mrite a script to copC the Ble sCstem from t:o directories to a ne: directorC in such a :aC that onlC the latest Ble is copied in case there are common Bles in both the directories; echo !CopC all Bles from one directorC to another directorC! echo !$nter (ull path forSource +irectorC! read s+ir echo !$nter (ull path for "ar8et +irectorC! read t+ir cp 1/u )s+ir )t+ir Ge;8 for current directorC Cou place ;;5PdirNameK N *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script Gif Cou :ant to copC in current directorC then ;;5Pne: +irectorC NameK (Q) :rite a script to compare identicallC named Bles in t:o diRerent directories and if theC are same, copC one of them in a third directorC; echo !/ead Bles from Brst +irectorC! read s+ir echo !/ead Bles from second +irectorC! read t+ir ls 1d echo )s+ir cd ;;5)s+ir ls 1l Bles<,ls 1a, (J) Mrite a script to delete Sero siSed Bles from a 8ien directorC (and all its sub1directories); echo !+$&$"$ T$/' SIT$+ (I&$S! echo ,Bnd ; 1tCpe f 1siSe ?,Klist cat list Bnd ; 1tCpe f 1siSe ? 1e-ec rm UV 0W ls 1l (H) Mrite a script to displaC the name of those Bles (in the 8ien directorC) :hich are hain8 multiple lin9s; echo !+ispalC Bles :ith multile lin9s! echo ,Bnd ; A 1lin9s =, (X) Mrite a script to displaC the name of all e-ecutable Bles in the 8ien directorC; echo !All $-ecutabel (iles from current +irectorC! O *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script Bnd ; 1perm 5u<-,8<-,o<- echo !$nter absolute path for a directorC! read path Bnd )path 1perm 5u<-,8<-,o<- (=?) :rite a script to displaC the date, time and a :elcome messa8e (li9e Dood 2ornin8 etc;); "he time should be displaCed :ith Ya;m;Z or Yp;m;Z and not in 2N hours notation; echo !2ornin8 :ish! date hour<,date6cut 1c=21=L, if > )hour 18e ? 1a )hour 1le =2 @ then echo !Dood 2ornin8;;AA! elif > )hour 18e =2 1a )hour 1le =H @ then echo !Dood AfterNoon;;AA! elif > )hour 18e =H 1a )hour 1le 2? @ then echo !Dood $enin8;;AA! else echo !Dood Ni8ht;;AA! B (==) Mrite a script to displaC the directorC in the descendin8 order of the siSe of each Ble; echo !&ist of all Bles in descendin8 order from a directorC! echo $nter +irectorC read direc cd )direc ls 1Sl (=2) Mrite a script to implement the follo:in8 commands: "ree (of +'S) echo Y"ree CommandZ tree Q *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script :hich (of UNIX) (=L) Mrite a script for 8eneratin8 a mar9 sheet after readin8 data from a Ble; (ile contains student roll no, name , mar9s of three subjects; echo !/ead data from Student2ar9Sheet Ble! echo !Student /ollNo! echo ,cat Student2ar9sheet 6cut 1f =, echo !$nter StudentIs /oll No :! read rNo lNo<,e-pr )rNo . =, ro:<,head 1)lNo Student2ar9sheet 6tail 1=, echo !StudentIs +etail )ro:! m=<,head 1)lNo Student2ar9sheet 6tail 1=6cut 1f L, m2<,head 1)lNo Student2ar9sheet 6tail 1=6cut 1f N, mL<,head 1)lNo Student2ar9sheet 6tail 1=6cut 1f O, total<,e-pr )m= . )m2 . )mL, echo )total per<,e-pr )total 5 L 6 bc, if > )per 18e Q? @ then 8rade<!(irst! elif > )per 18e O? 1a )per 1le OX @ then 8rade<!Second! elif > )per 18e N? 1a ) per 1le NX @ then 8rade<!"hird! else 8rade<!(ail! B echo !3ercenta8e : ! )per echo !Drade : ! )8rade J *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script ((ile Student2ar9sheet[s detail li9e := /am ON XJ JH) (=N) Mrite a script to ma9e follo:in8 Ble and directorC mana8ement operations menu based: +isplaC current directorC &ist directorC 2a9e directorC Chan8e directorC CopC a Ble /ename a Ble +elete a Ble $dit Ble echo ! =:+isplaC current +irectorC! echo ! 2:&ist +irectorC! echo ! L:2a9e directorC ! echo ! N:Chan8e directorC ! echo ! O:CopC a Ble ! echo ! Q:/ename a fIle ! echo ! J:+elete a Ble ! echo ! H:$dit a Ble ! echo ! $nter Four Choice: ! read ch case )ch in =) p:d WW 2) ls 1d WW L) echo $nter directorC name to ma9e read dir\name m9dir )dir\name WW N) H *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script cd WW O) echo $nter t:o Ble name to copC read f\name= f\name2 cp )f\name= )f\name2 WW Q) echo $nter Ble name to rename read fname m )fname WW J) echo $nter Ble name to delete read fname rm )fname WW H) echo $nter Ble name to edit read fname i )fname WW 4) echo Fou h entered :ron8 choice WW esac (=O) Mrite a script :hich reads a te-t Ble and output the follo:in8 Count of character,:ords and lines; (ile in reerse;(reEuencC of particular :ord in the Ble; &o:er case letter in place of upper case letter; echo !0n $nter (ilename : ! read Blen echo !11111111111111111111111111111111111111111111111111111111111111! echo ! 2$NU ! echo !11111111111111111111111111111111111111111111111111111111111111! echo ! a) Count the no; of char;s, :ords, lines;! echo ! b) +isplaC a Ble in reerse;! echo ! c) Count the no; of occurrences of a particular :ord;! echo ! d) Conert &o:er case to UppeCase! X *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script echo !11111111111111111111111111111111111111111111111111111111111111! echo !0n $nter Four Choice : ! read c case !)c! in a) echo !0n "otal lines,:ords,char;s ! :c )Blen WW b) re )Blen K temp Gread buf cat temp WW c) echo !0n$nter :ord to Bnd :! read : for i in ,cat )Blen, do echo )i KK f=;t-t done echo !"otal no; of :ords< 0c! W 8rep 1c ): f=;t-t 8rep ): f=;t-t rm f=;t-t WW d) echo !See )Blen Ble for output;;;! tr >a1S@ >A1T@ P )Blen WW 4) echo !Inalid choice! esac (=Q) Mrite a shell script to chec9 :hether the named user is currentlC lo88ed in or not; echo !enter user name! read n :ho 6 8rep !])n! if > )^ 1eE ? @ =? *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script then echo !currentlC lo8 in! else echo !not lo8 in! B (=J) Mrite a Script for Simple +atabase 2ana8ement SCstem 'peration; +atabase (ile Contains (ollo:in8 (ields; $23\N' $23\NA2$ $23\A++/$SS $23\AD$ $23\D$N+$/ $23\+$SIDNA"I'N $23\*ASIC\SA&A/F 3roide 2enu +rien (acilitC (or %I$M /$C'/+ *AS$+ 'N _U$/F A++ /$C'/+ +$&$"$ /$C'/+ 2'+I(F /$C'/+; C'UN" "'"A& NU2*$/ '( /$C'/+S $XI" >ma9e a Ble $mp;t-t :ith follo:in8 data $23\N':$23\NA2$:$23\A++/$SS:$23\AD$:$23\D$N+$/:$23\+$S IDNA"I'N:$23\*ASIC\SA&A/F@ Ge-ec cat $mp;t-t ch<!C! :hile > )ch < !C! @ do echo !A%AI&A*&$ C#'IC$S::! echo !=;Add Ne: /ecord::! == *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script echo !2;%ie: /ecord::! echo !L;2odifC /ecord::! echo !N;Count total number of records::! echo !O;$-it::! echo !$nter Cou choice::! read no case )no in =)len8<,cat $mp;t-t6:c 1l, G len<,echo )((len1=)), echo !enter $mp Name ::! read ename echo !enter $mp Address ::! read eadd echo !enter $mp A8e ::! read ea8e echo !enter $mp Dender::! read e8en echo !enter $mp +esi8ation! read edes echo !eneer $mp *asic SalarC ! read esal echo )len8:)ename:)eadd:)ea8e:)e8en:)edes:)esal KK $mp;t-t e-ec cat $mp;t-t WW 2) lent<,cat $mp;t-t6:c 1l, if > )lent 1eE = @ then echo !No +ata in (ile aailable! else echo !$nter $mploCee number to Bnd data :: ! read empno if > )empno 18t )((lent1=)) 1o )empno 1lt = @ then echo !$ntered $mploCee no not aailable in +atabase ! else old<,8rep ])empno $mp;t-t, echo !/ecord :: )old! =2 *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script B B WW L) len<,cat $mp;t-t6:c 1l, echo )len echo !$nter $mploCee Number U :ant to modifC ::! read empno if > )empno 18t )((len1=)) 1o )empno 1lt = @ then echo !$ntered +ata is not aailable for 2odiBcation! e-it else cur<,8rep 1s )empno $mp;t-t 6 cut 1f= 1d !:!, count<? for i in ,cat $mp;t-t 6 cut 1f= 1d !:!, do if > )i 1eE )empno @ then brea9 else count<,echo )((count.=)), B done Gecho !C'UN" :: )count! head 1)count $mp;t-t K temp=;t-t j<? cn<= Gold<,8rep 1s )empno $mp;t-t 6 cut 1f=1J 1d !:!, old<,8rep ])empno $mp;t-t, for i in ,cat $mp;t-t 6 cut 1f= 1d !:!, do if > )i 1eE )empno @ then echo !Aailbale 'ld %alus in /ecord : : )old! echo !enter $mp Name ::! read ename echo !enter $mp Address ::! =L *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script read eadd echo !enter $mp A8e ::! read ea8e echo !enter $mp Dender::! read e8en echo !enter $mp +esi8ation! read edes echo !eneer $mp *asic SalarC ! read esal echo )empno:)ename:)eadd:)ea8e:)e8en:)edes:)esal KK temp=;t-t B done B ne:<,echo )len1)count1= 6bc, tail 1n )ne: $mp;t-t KK temp=;t-t cp temp=;t-t $mp;t-t Grm temp=;t-t echo !(ile 2odiBed ::! cat $mp;t-t WW N) len<,cat $mp;t-t6:c 1l, len<,echo )((len1=)), echo !"otal Number of records aailable::!)len WW O) e-it WW 4)echo !Inalid 'peration Number! WW esac echo !+o Cou :ant to continue;;AA! read ch done =H; Mrite A Script "o 3erform (ollo:in8 Strin8 'perations Usin8 2enu: C'23A/$ "M' S"/INDS; `'IN "M' S"/INDS; (IN+ "#$ &$ND"# '( A DI%$N S"/IND; 'CCU//$NC$ '( C#A/AC"$/ AN+ M'/+S =N *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script /$%$/S$ "#$ S"/IND; :hile true do echo 111111111111111111111111111111111111111 echo =:C'23A/$ "M' S"/INDS echo 2:`'IN "M' S"/INDS echo L:(IN+ "#$ &$ND"# '( A DI%$N S"/IND echo N:'CCU//$NC$ '( C#A/AC"$/ AN+ M'/+S echo O:/$%$/S$ "#$ S"/IND echo 111111111111111111111111111111111111111 echo $nter Choice: read ch echo 111111111111111111111111111111111111111 case )ch in =) echo $nter Strin8=: read str= echo $nter Strin82: read str2 if > )str= < )str2 @ then echo Strin8 is eEual else echo Strin8 is not eEual B WW 2) echo $nter Strin8=: read str= echo $nter Strin82: read str2 strL<)str=)str2 echo `oin Strin8: )strL WW L) len8th<? =O *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script echo $nter Strin8=: read str= len8th<,e-pr )str= 6 :c 1c, len8th<,e-pr )len8th 1 =, echo &en8th: )len8th WW N) echo $nter Strin8: read str echo $nter Mord to Bnd read :ord echo )str 6 cat K str=;t-t 8rep 1o ):ord str=;t-t 6 cat K str2;t-t count<,8rep 1c ):ord str2;t-t, echo Count: )count WW O) echo $nter Strin8: read str ans<I I echo )ans len<,e-pr )str 6 :c 1c, len<,e-pr )len 1 =, :hile > )len 18t ? @ do re<,e-pr )str 6 cut 1c )len, Gtemp<)temp)re ans<)ans)re len<,e-pr )len 1 =, done echo /eerse Strin8: )ans WW 4) echo Mron8 Choice WW =Q *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script esac echo +o u :ant to continue^ read ans if > )ans < n @ then e-it B done =X; Mrite a script to calculate 8ross salarC for anC number of emploCees Dross SalarC <*asic . #/A . +A; #/A<=?7 and +A< =O7; >ma9e a Ble $mp;t-t :ith follo:in8 data $23\N':$23\NA2$:$23\A++/$SS:$23\AD$:$23\D$N+$/:$23\+$SID NA"I'N:$23\*ASIC\SA&A/F and run script =J;sh@ len<,cat $mp;t-t6:c 1l, :hile > )len 18t = @ do line<,cat $mp;t-t6 head 1)len 6 tail 1=, Name<,echo )line 6cut 1f 2 1d !:!, *\salarC<,echo )line 6cut 1f J 1d !:!, #/A<,echo )*\salarC 04 ;=? 6bc, =J *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script +A<,echo )*\salarC 04 ;=O 6bc, D/'SS<,echo )#/A . )+A . )*\salarC 6bc, echo !0n $mploCee Name:!)Name !0n111111111111111111111111111111111110n*asic SalarC: ! )*\salarC !0n#/A: ! )#/A !0n+A: ! )+A !0n"otal Dross SalarC: !) len<,e-pr )len 1 =, done 2?; Mrite a script to chec9 :hether a 8ien strin8 is palindrome or not; echo !$nter a Strin8! read str len<,echo )str 6:c 1c, i<)len :hile > )i 18t ? @ do -<,echo )str 6cut 1c)i1)i, temp<)temp!!)- i<,e-pr )i 1 =, done echo )temp if > )str < )temp @ then echo !pallindrom;;AA! else echo !Not 3allindrom;;AA! B (2=) Mrite a script to chec9 :hether a 8ien number is palindrome or not; clear echo !$N"$/ NU2*$/ :<! read number temp<)number rem<? reno<? :hile > )number 18t ? @ do rem<,echo )number 7 =? 6bc, =H *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script reno<,e-pr )reno 04 =? . )rem, number<,e-pr )number 5 =?, done echo !0n '/IDINA& NU2*$/ :1! )temp echo !0n /$%$/S$ NU2*$/ :1! )reno if > )temp 1eE )reno @ then echo !Number is pallindrom;;AA! else echo !Number is not pallindrom;;AA! B (22) Mrite a script to displaC all :ords of a Ble in ascendin8 order; echo 1n !$nter (ile Name: ! read Ble if > 1f )Ble @ then for i in ,cat )Ble, do ,echo )i KK t, done else echo !(ile +oes Not $-ist;;;! B sort t rm t (2L) Mrite a script to displaC all lines of a Ble in ascendin8 order; echo 1n !$nter (ile Name: ! read Ble if > 1f )Ble @ then sort )Ble else echo !(ile +oes Not $-ist;;;! B =X *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script (2N) Mrite a script to displaC the last modiBed Ble; echo !&ast modiBed Ble! Bles<,ls 1l6:c 1l, i<2 :hile > )i 1lt )Bles @ do line<,ls 1lt6head 1)i6tail 1=, j<= :hile > )j 1le H @ do Beld<,echo )line6cut 1f)j 1d! !, str<)str!:!)Beld j<,e-pr )j . =, done str<)str!0n! echo )str KK temp;t-t i<,e-pr )i . =, done Gremoe all blan9 lines sed I5])5dI temp;t-t KK ls;t-t last2odi<,cat ls;t-t6head 1=6tail 1=6cut 1f=? 1d!:!, echo )last2odi rm temp;t-t rm ls;t-t ls alt 2? *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script (2O) Mrite a shell script to add the statement Ginclude Pstdio;hK at the be8innin8 of eerC C source Ble in current directorC containin8 printf and fprintf; echo !Incluede line GincludePstdio;hK in all c Ble! c(ile<,Bnd ; 1name !4;c!, str<!GincludePstdio;hK! for i in )c(ile do pCount<,8rep 1c I]printfI )i 6cut 1f 2 1d!:!, fCount<,8rep 1c I]fprintfI )i 6cut 1f 2 1d!:!, iCount<,8rep 1c I]GI )i 6cut 1f 2 1d!:!, if > )pCount 18t ? 1a )fCount 18t ? 1a )iCount 1eE ? @ then rm tempc echo )str K tempc cat )i KK tempc rm )i cp tempc )i B done (2Q) Mrite a script that behaes both in interactie and non1interactie mode; Mhen no ar8uments are supplied, it pic9s up each C pro8ram from current directorC and lists the Brst =? lines; It then prompts for deletion of the Ble; If the user supplies ar8uments :ith the script, then it :or9s on those Bles onlC; echo !3erform operation as per passed ar8ument! totalAr8<,echo )G, if > )totalAr8 1eE ? @ then echo !No ar8ument supplied! c(iles<,Bnd ; 1name !4;c!, for i in )c(iles do echo !(ile!)i echo !(irst =? lines of ;c Ble! head 1=? )i echo !+o Cou :ant to remoe this Ble>Fes:F6No:N@! read ch if > !)ch! < !F! 1o !)ch! < !C! @ 2= *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script then echo !User :ant to delete this Ble! )i rm 1i )i else echo !User +oes not :ant to delete Ble! )i B done else if > 1f )= @ then echo !(ile $-ist! i )= else echo !(ile does not $-ist! B B (2J) Mrite a script that deletes all leadin8 and trailin8 spaces in all lines in a Ble; Also remoe blan9 lines from a Ble; &ocate lines containin8 onlC printf but not fprintf; echo !/emoe all leadin8 and trailin8 space alon8 :ith blan9 lines from a 8ien) echo !$nter Ble name! read fName if > 1f )fName @ then G delete *'"# leadin8 and trailin8 :hitespace from each line sed Is5]> 0t@455Ws5> 0t@4)55WI )fName Ktemp sed I5])5dI temp m temp )fName Gremoe all blan9 lines from a Ble G sed I5])5dI )fName else 22 *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or UNIX Shell Script echo !(ile does not e-ist! B 2L *IC1Chaparda >:::;8tu1mca;blo8spot;com@ 3repared *C: *har8a /ajCa8or