[ Pobierz całość w formacie PDF ]
.9.How to calculate 5.12 + 2.5 real number calculation at $ prompt in Shell ?Answer: Use command as , $ echo 5.12 + 2.5 | bc , here we are giving echo commands output to bc tocalculate the 5.12 + 2.5Q.10.How to perform real number calculation in shell script and store result tothird variable , lets say a=5.66, b=8.67, c=a+b?Answer: See Q10 shell Script.Q.11.Write script to determine whether given file exist or not, file name is supplied as command lineargument, also check for sufficient number of command line argumentAnswer: See Q11 shell Script.Q.12.Write script to determine whether given command line argument ($1) contains "*" symbol or not, if$1 does not contains "*" symbol add it to $1, otherwise show message "Symbol is not required".For e.g.If we called this script Q12 then after giving ,$ Q12 /binHere $1 is /bin, it should check whether "*" symbol is present or not if not it should print Required i.e./bin/*, and if symbol present then Symbol is not required must be printed.Test your script as$ Q12 /bin$ Q12 /bin/*Answer: See Q12 shell ScriptQ.13.Write script to print contains of file from given line number to next given number of lines.For e.g.Ifwe called this script as Q13 and run as$ Q13 5 5 myf , Here print contains of 'myf' file from line number 5 to next 5 line of that file.Answer: See Q13 shell ScriptQ.14.Write script to implement getopts statement, your script should understand following command lineargument called this script Q14,Q14 -c -d -m -eWhere options work as-c clear the screen-d show list of files in current working directory-m start mc (midnight commander shell) , if installed-e { editor } start this { editor } if installedAnswer: See Q14 shell ScriptQ.15.Write script called sayHello, put this script into your startup file called.bash_profile, the scriptshould run as soon as you logon to system, and it print any one of the following message in infobox usingdialog utility, if installed in your system, If dialog utility is not installed then use echo statement to printmessage : -Good MorningGood AfternoonGood Evening , according to system time.Answer: See Q15 shell ScriptQ.16.How to write script, that will print, Message "Hello World" , in Bold and Blink effect, and in differentcolors like red, brown etc using echo command.Answer: See Q16 shell ScriptQ.17.Write script to implement background process that will continually print current time in upper righthttp://www.freeos.com/guides/lsst/maspc.htm (16 of 17) [17/08/2001 17.42.32]Linux Shell Script Tutorialcorner of the screen , while user can do his/her normal job at $ prompt.Answer: See Q17 shell Script.Q.18.Write shell script to implement menus using dialog utility.Menu-items and action according to selectmenu-item is as followsMenu-Item Purpose Action for Menu-ItemDate and time must be shown using infobox of dialogDate/time To see current date timeutilityCalendar To see current calendar Calendar must be shown using infobox of dialog utilityFirst ask user name of directory where all files arepresent, if no name of directory given assumes currentdirectory, then show all files only of that directory, Filesmust be shown on screen using menus of dialog utility,Delete To delete selected filelet the user select the file, then ask the confirmation touser whether he/she wants to delete selected file, ifanswer is yes then delete the file , report errors if anywhile deleting file to user.Exit To Exit this shell script Exit/Stops the menu driven program i.e.this scriptNote: Create function for all action for e.g.To show date/time on screen create functionshow_datetime().Answer: See Q18 shell Script.Q.19
[ Pobierz całość w formacie PDF ]