SHELL PROGRAMMING
When a group of commands has to be executed regularly, they should be stored in a file,
and the file itself executed as a shell script or shell program. Though it’s not mandatory,
we normally use .sh extension for shell scripts.
A shell program runs in interpretive mode. It is not compiled into a separate executable file as a C program is. Each statement is loaded into memory when it is to be executed.
Installing any Ubuntu/Linux package using the command:
sudo apt-get install [package_name]
Ex:
To install gedit editor
>-sudo apt-get install gedit
Creating a file in gedit editor
>-sudo gedit [file_name]
Ex:
>- sudo gedit shell_program_1.sh
Few Examples Of Shell Codes:
1
............................................................................................................
shell_program_1.sh
............................................................................................................
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Program: execute simple command | |
echo "Today's date: `date`" |
............................................................................................................
For Execute Type:
>-sh shell_program_1.sh
in the Terminal.
2
............................................................................................................
shell_program_2.sh
............................................................................................................
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash/ | |
#Program: execute simple commands | |
echo "This month calender: \n" | |
cal feb 2019 | |
echo "My shell is : $SHELL" |
............................................................................................................
Execute: sh shell_program_2.sh
............................................................................................................
thanks
ReplyDelete