Search
| How to start bash scripting? |
|
|
|
| Programming - Bash |
| Tuesday, 07 July 2009 07:11 |
|
To begin with bash scripting, let me introduce you to bash scripting. Bash script file is a file which consists of a sequence of bash commands to be executed starting with an interpreter. It helps you to reduce the time by avoiding repetitive use of commands in the terminal. Instead you can type that sequence of commands in order to a scripting file and save. Procedure Open a new file. We must first specify the shell we are using. It should preceed with a #! called 'shebang'. It provides the path to to the interpreter.Usually we use '/bin/sh' for using the default shell. '/bin/sh is a pointer to our default shell'. Or we can specify the shell as '/bin/bash'. Then we start writing the series of commands to be executed. Any line preceeding with a '#' is considered as a comment. An example of a shell scripting file is given below.
#!/bin/bash
Then above commands are for listing the file residing in our home directory in a long format. Save the file as list.sh. We should give an extension .sh to identify the scripting file. It will work even if there is no extension. Then we must add the executable permission to file by the command
chmod u+x list.sh
Now you can run the file by typing at your terminal
./test.sh
|
| Last Updated on Wednesday, 08 July 2009 07:08 |




