Skip to content

Latest commit

 

History

History

practise1

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Shebang-Everything

Your unofficial guidebook to shell programming

Programs for practise

Write scripts for following programs yourself, if you are not able to solve them you can see the code.

Program 1

Write a shell script that prints "Hello World!" to the screen.

See the code here!

Program 2

Assign some message to a variable and display that variable to screen.

See the code here!

Program 3

Store the value of date command in a variable and display the message "Today is: _______" where, _____ represents output of date command.

See the code here!

Program 4

Check whether /random exists.

See the code here!

Program 5

Write a program to print your 5 favourite fruits.

See the code here!

Program 6

Write a program to take address of file as arguement and then check the file type. (Hint! use file command)

See the code here!

Program 7

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.

See the code here!

Program 8

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.

See the code here!

Program 9

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 non­zero exit status report "Command Not Executed!" and exit with a 1 exit status.

See the code here!

Program 10

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.

See the code here!