Programming Tutorials

linux Tutorials

31. Using System Time in Shell Script

By: Vivek G : 2011-01-29

Description: This shell script shows to print any one of the following message in infobox using dialog utility, if installed in your system, If dialog utility is not installed then use echo statement to print message


32. Print contents of a file using Shell Script

By: Vivek G : 2011-01-29

Description: This shell script prints contents of file from given line number to next given number of lines. For e.g. If we called this script as printfile and run as $ printfile 5 5 myfile , Here print contents of 'myfile' file from line number 5 to next 5 line of that file.


33. sum of all digits in a given number using Shell Script

By: Dorris : 2011-01-29

Description: This shell script prints the given number's sum of all digits, For eg. If no is 123 it's sum of all digit will be 1+2+3 = 6.


34. if...else...fi in Linux Shell Script

By: Dorris : 2011-01-15

Description: If given condition is true then command1 is executed otherwise command2 is executed.


35. if condition in Linux Shell Script

By: Dorris : 2011-01-15

Description: if condition which is used for decision making in shell script, If given condition is true then command1 is executed.


36. test command or [ expr ] in Linux Shell Script

By: Dorris : 2011-01-15

Description: test command or [ expr ] is used to see if an expression is true, and if it is true it return zero(0), otherwise returns nonzero for false.


37. Nested if-else-fi in Linux Shell Script

By: Dorris : 2011-01-15

Description: You can write the entire if-else construct within either the body of the if statement of the body of an else statement. This is called the nesting of ifs.


38. Multilevel if-then-else in Linux Shell Script

By: Dorris : 2011-01-15

Description: Above program gives error for last run, here integer comparison is expected therefore error like "./elf: [: -gt: unary operator expected" occurs, but still our program notify this error to user by providing message "


39. for loop in Linux Shell Script

By: Dorris : 2011-01-15

Description: The for loop first creates i variable and assigned a number to i from the list of number from 1 to 5, The shell execute echo statement for each assignment of i. (This is usually know as iteration) This process will continue until all the items in the list were not finished, because of this it will repeat 5 echo statements. To make you idea more clear try following script:


40. Nested for loop in Linux Shell Script

By: Dorris : 2011-01-15

Description: As you see the if statement can nested, similarly loop statement can be nested. You can nest the for loop. To understand the nesting of for loop see the following shell script.