For creating a shell script, just open your vi editor or any other editor you are using to create files. In the editor type in the following two statements.
echo "Hello World!!"
echo "This is a shell script"
After typing in the statements, save the file with some filename say "abc".
There are two methods of running this shell script :
1. Use sh command on the shell prompt, like
$ sh abc
sh <shellscriptname> is used to execute the shell script passed to it as argument.
2. Other way is to change your shell script properties to executable. You can use chmod command on the shell prompt to change the properties of your shell script file to executable, such as :
$ chmod 755 abc
Where, chmod is the command which changes the properties of a file. 7 means you are giving read+write+executable permissions to the owner of the file i.e. you. 5 means you are giving read+write permissions to the group owners of the file. Next 5 means you are giving read+write permissions to other users. After using this command, your file i.e. shell script is now executable i.e. we can just type in its name on the shell prompt and it will gets executed, like :
$ abc
and , just after giving this command, the statements stored in the abc file will gets executed on your shell prompt.
Bookmarks