You are on page 1of 20

1)WriteashellprogramusingbashtoimplementATMfunctionality.Letitoffertheuserthe choiceofCashwithdrawal,CashRemitting,ChangePassword,Thirdparty transferandexit.Oncetheuserhasmadeachoice,havetheprogramaskthe userfornecessaryinformation,insuchawaythathiscurrentpasswordis"123" andthetotalamountinhisaccountisRs20000/.

Iftheuserinputiswrong meansithastoworkaccordingly 2)Writecommandstodothefollowing a)FindthePresentworkingDirectory b)Findtheuserscurrentlyloggedin c)Viewthecontentsofanyfile d)renameafile e)changethepasswordofanyuser f)Deleteadirectory g)Displaythecurrenttime h)createauser i)Viewonlytop5linesofafile j)createanewdirectory 3)Explainthefollowingcommands i. Printf 2.who 3.whereis 4.file 5.grep

4)A)WriteascripttoprintFibonacciseriesusingbash?Explaintheworkingofthescript. B)WriteabashscripttocheckwhetheranumberisArmstrongornot?Explaintheworkingof thescript. 5)A)Writeashellscriptthatwilldisplaythefollowingmenu ii. Issueabook iii. Returnabook iv. Deleteabook. Eachoftheaboveoptionsshouldhaveasubmenuthatasksforthename ofthebookandthethenechotheactionthatisdone.Explaintheworkingofthecommands usedandtheconditionalstatementusedinthescript.

B)Writeascriptusingbashthatwilltaketwonumbersfromtheuserandgeneratethe multiplicationtableforthefirstnumbertillthelimitmentionedbythesecondnumber. Explaintheworkingofthecommandsandtheloopingstatementusedinthescript. 6)Writeshellscripttoshowvarioussystemconfigurationlike 1. Currentlyloggeduserandhislogname 2. Yourcurrentshell 3. Yourhomedirectory 4. Youroperatingsystemtype 5. Yourcurrentpathsetting 6. Yourcurrentworkingdirectory 7. ShowCurrentlyloggednumberofusers 8. Aboutyourosandversion,releasenumber,kernelversion 9. Showallavailableshells 10. Showcomputercpuinformationlikeprocessortype,speedetc 7)Writeshellscriptusingforlooptoprintthefollowingpatternsonscreen.Explaintheworkingof thescript. A)$ $$ $$$ $$$$ $$$$$ B)# ## ### #### ##### ##### #### ### ## #

8)A)Writeaninteractiveshellprogram.Letitoffertheuserthechoiceof copying,removing,renamingandexit.Oncetheuserhasmadeachoice,have theprogramasktheuserfornecessaryinformation,suchasthefilename,new nameandsoon. B)Differencebetweenscriptingandprogramming

9)A)Usemetacharachtersandwriteshellscriptsandexplain i)Listallthefilesinthecurrentdirectoryhaving"i"asthesecondletterintheirnames ii)Listallthefilesinthecurrentdirectoryhavingletter"a"intheirnames iii)Removeallthedirectorieswhichendwith"run"inthepresentdirectory iv)Removeallthefileswithextension.cpp B)Makeashellscriptusinggrepthatcheckswhetherauserexistsin/etc/passwd.Givethe usernameasinputtothescript. 10A)WriteascriptinbashwhichisabletoacceptLinuxcommandsasinput.Thescriptmustbe abletoexecutethatcommandswhichtheusergives.Iftheenteredcommandisnotavalidoneit shouldshowerrormessage. B)Writeascripttocheckwhetherthegivenuserinputisevenorodd C)Writeascripttocheckwhetheranumberispalindromeornot 11)A).Classifyeachofthefollowingassimple,complex,orcompoundcommands: i. $ls ii. $date iii.$lsl iv.$echo"helloworld" B)Writeascriptwhichreadsanumberinunitsofsecondsandconvertsitto theunitshours:minutes:secondsandprintstheresulttostandardoutput. Yourscriptmustpromptforreinputifanegativevalueisinput 12)A)WriteascripttofindFibonacciusingfunction? B)Writeascripttocheckwhethertheuserinputisavowelornotusingfunction 13)Usemetacharacterstowritethescripts A)Listallthefilesinthedirectoryandsubdirectoryincludinghiddenfiles B)Removeallfilesstartingwithainthecurrentdirectory C)Copyallthefileswhichcontain'a'tofolder"Linux"fromthepresentdirectory D)Listallthefileswhichhasthefourthletteras'a'

E)Listallthefilesinthepresentworkingdirectorywhichhasnumericals

14)A)Writeashellscripttoprint9,89,7,6,56,1indescendingandascendingorderKeepthis numbersinsideafilenamedasnameandredirecttheoutputtoanotherfilenamedasout. Explaintheworkingofscriptandthecommandsused. B)Writeshellscripttochangethewordslistedbelowtouppercaseandredirecttheoutputto thefilenamedastest1.Thesewordsarestoredinafilewhosenameistest? remya kartik priya divya devi Explaintheworkingofscriptandthecommandsused. C)Writeashellscripttoremovetheduplicateconsecutivelinesfromthefile3andredirectitto filenamedasoutput.Thecontentintheinputfileis prerana Ihaveapen Ihaveapen Ihaveapencil Explaintheworkingofscriptandthecommandsused. D)Writeascripttofindthecurrentdirectoryyouareworkinginandthencountthenumberof directoriesthatyouhavetochangefromthe"/"toreachyourdirectory. Explaintheworkingofscriptandthecommandsused. E)Createascripttocountthenumberofuserscurrentlyloggedin. 15)A)Writeascripttocountthependingjobs B)Howdoyoulistonlydirectories?Explaintheworkingofscriptandthecommandsused. C)Howdoyoucountthenumberofitemsthatbeginwithgork?Explaintheworkingof scriptandthecommandsused.(donotusesedandawk) D)Writeascripttodeletealltemporarilyfilesinlocation/tmpeverydayat midnight 16)(a)Theuserberthahasmarkedanimportantlineofoneofhertextfileswithan asterix(*).Butnowsheforgotthenameofthefile.Howcouldyoufindthisfile,

assumingitislocatedinberthashomedirectory?Exaplintheworkingofthescript. (b)Howdoyoulistonlydirectories?Explaintheworkingofscriptandthecommands used. (c)Howdoyoucountthenumberofitemsthatbeginwithgork?Explaintheworkingof scriptandthecommandsused. (d)WriteascriptusingcasewhichisabletoacceptLinuxcommandsasinput.Thescript mustbeabletoexecutethatcommandswhichtheusergives.Iftheenteredcommandis notavalidoneitshouldshowerrormessage.Explaintheworkingofscriptandthe conditionalstatementused. 17)A)Writecommandstodothefollowing 1. changetimestampings 2. changeowner 3. changegroup 4. changethepasswordofanyuser 5. Givepermissiontofiles B)WriteascripttochangeanydecimalnumbertoHex,oct,binary DuringtheexcecutionofthescriptthesignalsCtrl+CandCtrl+zshouldnotinterrupt.

18)A)Whatpurposedoesthefollowingline#!/bin/shserveinascript?Howwouldtheline changeifyouwereusingacshell B)writeascripttogiveexecutepermissiontoalltheshellscripts(filesending with.sh)inyourdirectory C)Whatareinvisiblefiles?Howdoyouuselstolistthem? D)Copyaparagraphoftextfromanydocumentornetintoafile.Nowwritea scriptthatwouldcountthenumberoftimestheword"the"appears.(don'tuse grep) E)Whichoptionsshouldbespecifiedtowcinordertocountthenumberoflinesand charactersinafile? 19)Writeshellscriptusingforlooptoprintthefollowingpatternsonscreen.Explainthe workingofthescript. A)1 22 333 4444

55555 B)1 12 123 1234 12345 C)Explainanythreedifferencebetweensoftlinkandhardlink 20) (a)Giventhathw1,hw2,ch1,andch2arefilesandbookandhomeworkaredirectories, whichofthefollowingcommandsgeneratesanerrormessage?Givereasonsforyour answer.a.$cphw1ch2homeworkb.$cphw1homeworkhw2bookc.$rmhw1 homeworkch1d.$rmhw2ch2 (b)Whichofthefollowingareabsolutepathnames?Whicharerelative?Explainyour answers. a./usr/local/binb.../../home/rangac.docs/book/ch01d./ (c)Whatcommandshouldbeusedtocopythedirectory/usr/localto/opt/pgms?Explain theworkingofthecommand. (d)Whatcommand(s)shouldbeusedtomovethedirectory/usr/localto/opt/pgms? Explaintheworkingofthecommand. (e)Giventhefollowinglistingforthedirectorybackup,canyouusethermdircommand toremovethisdirectory?Ifnotwhyandgiveacommandthatcanbeused. $lsabackup ./../sysbak980322sysbak980112 21)Writeshellscriptsforthefollowing.Explainthecommandsusedandtheworkingofthescripts (donotusesedandawk) 1. Taketwonumbersasinputfromuser,findwhichisgreater 2. Countthenumberoftimesthewordtheappearsinagivenfile. 3. Listallthelinesthebeginwithanumber 4. Countthenumberofblanklines 5. Searchforallnumbersinafileandsortthem.

22)Writescriptsforthefollowing(donotusesedandawk)Explainthecommandsusedandthe workingofthescripts a)Printonlythecurrentday,notthedate b)Listallthewordsthathavethelettereinit. c)Listalltheusersthatexistinyoursystem

d) Countthenumberofdirectoriestobechangedtoreachthepwd c)Addlinenumberstoafile. 23(a)Writeaselectloopthatlistseachfileinthecurrentdirectoryandenablestheusertoview thefilebyselectingitsnumber.Inadditiontolistingeachfile,usethestringExitProgramasthe keytoexittheloop.Iftheuserselectsanitemthatisnotaregularfile,theprogramshould identifytheproblem.Ifnoinputisgiven,themenushouldberedisplayed. (b)Completethescriptusingtheappropriateprintfcommandstoperformthespecifiednumeric conversions. Explain the working of the script Assume that the input is always a number: #!/bin/sh if[$#lt2];then echo"ERROR:Insufficientarguments."; exit1; fi case"$1"in o):#convertthenumberstoredin"$2"intooctal ;; x):#convertthenumberstoredin"$2"intohexadecimal ;; e):#convertthenumberstoredin"$2"intoscientificnotation ;; *)echo"ERROR:Unknownconversion,$1!";; esac (c)RewritetheerrormessagesinthepreviousscripttoredirecttheiroutputtoSTDERRinstead ofSTDOUT.ExplainthedifferencebetweenSTDOUTandSTDERR. 24)WriteshellscripttoconvertfilenamesinafolderfromUPPERCASEtolowercasefile names. 25)Writescritpsthatwilldothefollowing(donotusesedandawk).Explainthecommandsused andtheworkingofthescripts a)Giveexecutepermissiontoallthefilesinadirectory b)Worklikethecommandls.

c)Takeanumberasinputfromuserandgeneratethetableforthesame d)Listallthewordsthathavelettertorrinit. c)Countonlythenumberoffilesinadirectory.

5X2=10

26)Writescriptsthatwilldothefollowing(donotusesedandawk).Explainthecommands usedandtheworkingofthescripts a)Readausernamefromtheuserandcreateauserbythatname. b)Readausernamefromtheuserandcheckiftheuserisloggedinornot. c)Takeastringandafilenameasinputfromuserandsearchforthesameinthegivenfile d)Takeinputoncommandlineandechotheminthescript,alsoechothenumberof argumentspassed. e)Takeintegersasinputonthecommandlineandfindtheaverageofthenumbersinthe script. 5X2=10 27)Usegrepandexplaineach 5X2=10

a)Howdoyousearchforastringinsideadirectory? b)Howdoyousearchforastringinadirectorywiththesubdirectoriesrecursed? c)Howwillyoulistonlytheemptylinesinafile? d)Howdoyousearchthestringforvowel'soccurrenceandnumberofoccurrencesofeach vowel? e)Canyoufindanalternativeforwcl? 28)(a)Writescripttodeterminewhethergivencommandlineargument($1)contains"*" symbolornot,if$1doesnotcontains"*"symboladditto$1,otherwiseshowmessage"Symbol isnotrequired".Fore.g.IfwecalledthisscriptQ12thenaftergiving,$Q12/binHere$1is/bin, itshouldcheckwhether"*"symbolispresentornotifnotitshouldprintRequiredi.e./bin/*, andifsymbolpresentthenSymbolisnotrequiredmustbeprinted.Explaintheworkingofyour scriptforthefollowingcases. $Q12/bin $Q12/bin/* (b)Writescripttoprintcontentsofafilefromgivenlinenumbertonextgivennumberoflines. Fore.g.IfwecalledthisscriptasQ13andrunas$Q1355myf,Hereouputwillbecontentsof 'myf'filefromlinenumber5tonext5lineofthatfile. 30)Writescripttoimplementgetoptsstatement,yourscriptshouldunderstandfollowing commandlineargumentcalledthisscriptQ14.Explaintheworkingofthescript Q14cdmeWhereoptionsworkas cclearthescreen dshowlistoffilesincurrentworkingdirectory mstartmc(midnightcommandershell),ifinstalled e{editor}startthis{editor}ifinstalled

31)UsingdialogutilitywriteascripttoimplementATMfunctionality.Letitoffertheuserthe choiceofCashwithdrawal,CashRemitting,ChangePassword,Thirdpartytransferandexit. Oncetheuserhasmadeachoice,havetheprogramasktheuserfornecessaryinformation,in suchawaythathiscurrentpasswordis"123"andthetotalamountinhisaccountisRs 20000/.Iftheuserinputiswrongmeansithastoworkaccordingly. conditions: (1)titleATMmachine (2)backtitle:SBIBANK (3)Onlyforexititneedtocomeoutoftheutility (4)CashWithdrawal,cashremittingandthirdpartytransferyouneedtoshowthebalance amount 32)a)Writethecommandwhichisusedto 1)Changetheowner 2)Changefiletimestampstothecurrenttime 3)Viewafile 4)Showthediskfreespaceononeormorefilesystems. 5)Showhowmuchdiskspaceadirectoryandallitsfilescontain. 6)Deletealink.. b)Explainthestructureoflinuxkernelwithaneatdiagram 33)(a)Writeashellscriptthatwilladdtwonos,whicharesuppliedascommandlineargument, andifthetwonosarenotgivenshowerroranditsusage.Explaintheworkingofthescript. (b)WriteScripttofindoutbiggestnumberfromgiventhreenos.Nosaresuppliesas commandlineargument.Printerrorifsufficientargumentsarenotsupplied.Explainthe workingofthescript (c)Writescripttoprintnosas5,4,3,2,1usingwhileloop.Explaintheworkingofthescript. 34)WritescriptcalledsayHello,itshouldprintanyoneofthefollowingmessageininfobox usingdialogutility,ifinstalledinyoursystem,Ifdialogutilityisnotinstalledthenuseecho statementtoprintmessage: GoodMorning GoodAfternoon GoodEvening,accordingtosystemtime. 35)(a)Writescripttoprintgivennumberssumofalldigit,Foreg.Ifnois123it'ssumofall digitwillbe1+2+3=6.Explaintheworkingofthescript.

(b)Howtoperformrealnumbercalculationinshellscriptandstoreresulttothirdvariable, letssaya=5.66,b=8.67,c=a+b?Explaintheworkingofthescript. (c)Writescripttodeterminewhethergivenfileexistornot,filenameissuppliedascommand lineargument,alsocheckforsufficientnumberofcommandlineargument.Explainthe workingofthescript. 36)(a)Howtowritescript,thatwillprint,Message"HelloWorld",inBoldandBlinkeffect,and indifferentcolorslikered,brownetcusingechocommandExplaintheworkingofthescript. (b)Writescripttoimplementbackgroundprocessthatwillcontinuallyprintcurrenttimeinupper rightcornerofthescreen,whileusercandohis/hernormaljobat$prompt.Explaintheworking ofthescript. 37) Writeshellscripttoimplementmenususingdialogutility.Menuitemsandaction accordingtoselectmenuitemisasfollows:

38)

a)Brieflyexplainthefilesystemstructureinlinux b)Explainthevariousfieldsofpasswordfile

39)Writethealternativecommandsofthefollowingusingsedandexplain a)tail1filename b)head1filename c)tr"ABCDE""abcde"<filename d)catfilename e)grep'^new'filename 40)Createfileandkeepthefollowingdatainside. sl:no name age 1 deepu 21 2 priya 15 3 prithvi 13 4 nimmi 17

5 abi 18 6 arya 12 usesedandconvertthemto (a)sl:noname age 1 rekha 21 2 priya 15 3 prithvi13 4 nimmi 17 5 abi 18 6 arya 12 (b) sl:no name age 1 deepu 45 2 priya 15 3 prithvi 13 4 nimmi 17 5 abi 18 6 arya 12 (c) sl:no name age 1 deepu 45 2 priya 25 3 prithvi 12 4 nimmi 12 5 abi 15 6 arya 18 41)Writethefollowingscriptsusingsedandexplain a)printthelast10linesofafile b)printsection8thlineto12thlineofafile c)printlinenumber52 d)printthelast2linesofafile e)printthelastlineofafile 42)Writethefollowingscriptsusingsedandexplaineach a)Deletesection8thlineto12thlineofafile b)Deletelinenumber52 c)deleteALLblanklinesfromafile d)Optimisethecommand catfilename|sed'10q' e)Deletethelinesfrom45to50inafile 43)Writeandexplaintheworkingoffollowingscripts.

a)Writeasedscriptthatwilldeleteallthelinesinafilethathavethelettertheinit. Thefilebyitselfneednotbemodified,onlytheoutputshouldbemodified. b)Writeasedscriptthatwillprintallthatwillcountthenumberofblanklinesinafile.

c)Writeasedscriptthatwillremovethefirstwordofeveryline d)Writeasedscripttoprintthelinenumbersofeverylinethathasthewordtheinit. e)Considerafilethathasthefollowingcontents. a n aa nn aaa nnn Writeasedscriptthatwillmodifyitto n a nn aa nnn aaa 44)Createfileandkeepthefollowingdatainside. Helloworld IlikesLinux Mybrotherandsisteralsolikeslinux *** 10001 100001 100 123000 150000 usesedandconvertthemintothefollowing.Explaintheworkingofthecommands (a)Helloworld IlikesLinux Mybrotherandsisteralsolikesunix *** 10001 100001 100 123000 150000 (b)10001 (c)10001 100001 (d)*** (e)Howwillyouusethesedcommandtochecktheparticularuserisloggedinornot Explaintheworkingofthescript. 45)Writeasedscriptthatwilltaketwostringsandafilenameainputfromtheuser.

Lettheinputsbestring1,string2,andafilenamedtest.Writeandexplainscriptstodothe following a)Toappendthestring2ateveryplacestring1ispresentinthefiletest b)Toinsertthestring2ateveryplacestring1ispresentinthefiletest c)Deleteallthelinesinthefiletestthathavethestringtest d)Printtheallthelinenumbersinwhichstring1ispresentinthefiletest. e)Replacethewholelinethathasthestring1withonlystirng2. 46) Writeasedscriptthatwilltaketwostringsandafilenameainputfromtheuser.

Lettheinputsbestring1,string2,andfilenamedtest.Writeandexplainscriptstodothe following a)Deletethelinenexttotheonethathasstring1intest b)Printonlythelinesnexttoonesthathavestring1infiletest c)Printboththelines,onehavingthestring1andtheonenexttoit d)Deleteboththelines,onehavingthestring1andtheonenexttoit. e)Deleteonlythelinenexttotheonethathasthestringstring1, 47)Writeandexplainsedscriptstodothefollowing a)Takeastringasaninputfromtheuserandsurroundthestringbybracketsatallthe locationsisappearsintheinputfile b)ReplaceallthenumbersintheinputfilebytheletterNUM. c)ReplaceallthecapitalDwithsmalld. d)Replacethefirstletterineverylinebyablank. e)Deletealltheblanklinesinthefile. 48)Writeandexplainsedscriptstodothefollowing a)Deleteblanklinesonlyifthereare2continuousblanklines. b)Deletealinehavingthestringgoodonlyifthelinefollowingitisblank. c)Thatwillworklikethecommandcat d)ThatwilldeleteeverylinethatstartswithaT. e)Thatwillshowallthespecialcharactersinafile. 49)Considerthebelowfilep1.txtasyoursamplefileandwritescriptsusingsed onetwotwothree twofourfive

1 fivesixtwotwo 125 fivetwosix 12 a)Changeonlythesecondoccurrenceoftwoinallthelinestotwothree b)printthelastlineofafile c)printonlythefirsttwolines d)Deleteonlythe7thand9thlineofafile e)printonlytheoddnumbersinthefile 50)1)Writethealternatecommandsusingsed. a)sedn'3!p'filename b)sedn'/word/{ p }'filename c)catfilename|trd"[09]" d)sedn'$p'filename e)sed'3q'filename f)grepc""filename g)grepv'Hai'filename 2)Writeasedscripttoprinthowmanytimestheword"Hai"usedinthestartingofaline 3)Writeasedscripttoprintonlythelines 4)Deleteonlythelastlineofthefile 51)Considerfilea.txtisasampletakenfromtheoutputoflslwhichcontainsthefollowingand belowscriptshastobefilledusingawk total48

drwxrxrx7deepthisankardeepthisankar40962011110511:34Desktop rwrr1deepthisankardeepthisankar2472011110308:52dia drwxrxrx2deepthisankardeepthisankar40962011101309:06Documents drwxrxrx5deepthisankardeepthisankar409620 drwxrxrx2deepthisankardeepthisankar40962011092221:34Videos a)Countthenumberofdirectoriesalone b)Countthenumberoffilesalone c)Calculatetotalsizeofthefilesalone d)printonlythepermissionsandthefilenamesinthegivenbelowformat drwxrxrx:Desktop rwrr:dia drwxrxrx:Documents drwxrxrx:Downloads rwrr:examples.desktop drwxrxrx:linuxold drwxrxrx:Music drwxrxrx:ns drwxrxrx:Pictures drwxrxrx:Public drwxrxrx:Templates drwxrxrx:Videos e)printonlythefilenames

52)(a)Writeascriptusingawktofindfactorial.Explaintheworkingofthescript. (b)Writeascripttofindthesumofnumbers1to10byusingawk.Explaintheworkingofthe script. 53)Considerthebelowgivensamplefilewritethefollowingscriptsusingawk

a)Printthenumberoffieldsineachrow b)Countnonblanklines c)Filteroutblanklines d)Printaditionallineaftereachline e)Printaditionallineaftereachline,iflineisnotblank: 54)Writeandexplainawkscriptstodothefollowing a) b) c) d) e) Printthelastfieldofeveryline Thatworkslikethecommandcat Thatwillprintfirstcolumnofeverline,outputbeingseperatedby**. Thatwillnotoutputtheblanklinesinafile Thatwilloutputallthelinesotherthanthesecondline.

55)DescribethefollowingsystemvariablesusedinAWK,alsogiveexamplesofthesame. a) b) c) d) e) NF NR FILENAME ORS OFS

56)Usethe"date"functioninshellandwritethescriptsbelowusingawk a)printdate b)Generateareportlikethis date:5 month:Nov year:2011

c)Youneedtoprintthemonthincapitalsliketheoutputbelow date 5 month NOV year 2011 d)Youmustprinttheminutealone e)Youmustprintthehouralone 57)WriteandexplainawkscriptthatwilltakeanumberNasinputonthecommandline. Then countthenumberoflinesintheinputfilethathavefieldsgreaterthanNanddisplaythe completelines.Inplaceofthelinesthatdonothavetherequirednumber offieldsprint the differencebetweenthenumberoffieldsthatarepresentandN. 58)Writeandexplainawkscriptthatwilltaketwofilesasinputandfindthefilethathavemore numberofwordsinit. 58)Writeandexplainawkscriptthatwilltaketwofilesasinputandfindthefilethathavemore numberoflinesinit. 59)Writeandexplainawkscriptthatwilltaketwofilesasinputfromtheuserandprintoutthe differencesbetweenthem.Compareonlythecorrespondingfields. 60)Filename:student SNOSNAMEATTENDANCE MARK1MARK2 1 2 3 Joe Mary Lara 89 90 67 45 78 56 56 80 78

Performthefollowingfunctionsusingawkusingtheabovetable: a.Calculateaveragemarks b.Listhowmanystudentsarethere c.Calculatetotalnumberofstudentswhoseattendanceis>90% d.PrintJoesrecord e.Printalltherecordswithoutmarks

70)a)ExplainformatspecifiersandmodifiersrelatedtoprintfstatementinAWK b)Explainany5Arithmeticbuiltinfunctions. 71)a)ExplainthebasicstructureofAWKwithanexample b)Printallwordsthatappearmorethan10timesininput 72)a)ExplainENDandBEGINpatterninAWKwithanexample b)Printalllineswherethe3rdfieldmultipliedbythe4thfieldisbiggerthan500 c)Printalllinewherethe3rdfieldis100orthe4thfieldisbiggerthan50 73)a)Takeafilenameasinputandaddnumberstoeachlineinthefile. b)Writeaperlprogramprintthecoloumn1aloneiftheinputgivenis Roy 30 Priya 40 Shilpa 50 c)Writeaperlprogramtoreversebelowfilecontent samplefile: Roy 30 Priya 40 Shilpa 50 74)Writeaperlprogramtocreateahtmlfileusingfilehandlinginperlanddothefollowing Openthefile Write"Welometomcis"inthefile Createthetablegivenbelow Names Roy Revathi Rony Marks 50 40 30

Deletethegivenbelowelementsfromthatandprint Revathi 40 Rony Closethefile 75)a)Writeaprograminperltosortthebelowwordsinalphabeticalorder.Thewordsare "deepacatroseamanas" 30

b)Writeaperlprogramtocheckwhetherthenumberbytheuserasapalindromeornot 76)a)Writeaperlprogramtoreverseanumberwhichisgivenasinputfromtheuser b)Writeaprograminperltoreadastringandanumber,andprintsthestringthenumberof timesindicatedbythenumber,onseparatelines 78)Writeandexplainthecodeforthefollowingwithregardtoperl: a)UsingtheParameterArray(@_) b)PassingParametersbyReference

79)(a)Writeaperlprogramthatreadsalistofstringsonseparatelinesandprintsoutthelistin reverseorder. b)Writeaperlprogramthatreadsastringandanumberandthenprintsthestringthenumber oftimesindicatedbythenumberonseparatelines. c)Writeaperlprogramthatreadstwonumbers,andthenprintsouttheresult ofthetwonumbersmultipliedtogether. 80)Writeandexplainthecodeforthefollowingwithregardtoperl: a)Determiningthenumberofelementsinanarray b)Howtograbasliceofanarray 81)Writeaperlscripttocreateahtmlfileusingfilehandlinginperlanddothefollowing Openthefile Write"Welometomcis"inthefile Createthetablegivenbelow Names Marks Roy Revathi Rony 50 40 30

Addthegivenbelowelementsalsotothatandprint Pranav 40

Bobby Closethefile 82)

30

(a)Writeaperlprogramtocheckwhetheranumberisapalindromeornot. (b)Writeaperlprogramtoimplementthebubblesortonasetofnumbers.

83)a)Writeaperlprogramtostorephonenumbersinahash.Writeaprogramtolookup numbersbytheperson'sname. b)Writeaperlprogramtocapturealltheprimenumbersbetween2andanumbertheuser givesyou.

You might also like