Your unofficial guidebook to shell programming
Write scripts for following programs yourself, if you are not able to solve them you can see the code.
Write a shell script that prints "Hello World!" to the screen.
Assign some message to a variable and display that variable to screen.
Store the value of date
command in a variable and display the message "Today is: _______" where, _____
represents output of date
command.
Check whether /random exists.
Write a program to print your 5 favourite fruits.
Write a program to take address of file as arguement and then check the file type. (Hint! use file command)
Write a shell script that prints "This script will return an exit status 200" and make sure that the script does return with an exit status 200.
Write a shell script that accepts the absolute path to a file or directory as an argument, and if that file/dir exists, it returns with 0 exit status. Else, it makes creates that directory and then return with code 1.
Write a script that executes the command "cat /etc/shadow". If the command returns a 0 exit status report "Command Executed!" and exit with a 0 exit status. If the command returns a nonzero exit status report "Command Not Executed!" and exit with a 1 exit status.
Write a function in shell script to take a path as arguement and print the number of files/directories in that path.
Hint You can try copying the output of ls command in a text file and then count the number of lines in that file.