Bash programming: Difference between revisions
wikademia>Josh Sandlin New page: ==Bash Shell== One of the most powerful tools when programming for Linux is the Bash Shell. When coding for the Bash Shell, you are writing scripts that will be executed by the shell. Bash... |
wikademia>Erkan Yilmaz +cats |
||
| Line 15: | Line 15: | ||
alias nmp="nmap -vv -T Insane -P0 -O" | alias nmp="nmap -vv -T Insane -P0 -O" | ||
</source> | </source> | ||
[[Category:Linux]] | |||
[[Category:Programming]] | |||
Revision as of 16:35, 6 November 2007
Bash Shell
One of the most powerful tools when programming for Linux is the Bash Shell. When coding for the Bash Shell, you are writing scripts that will be executed by the shell. Bash Scripts are similar in nature to Batch scripts in Windows, but go much deeper into the operation of the OS.
What does it look like?
The Bash Shell syntax works very much like Batch, in that you use terminal commands. A sample script can be as simple as <source lang="bash">
- !/bin/bash
echo "hello world!" </source> and can be as complex as script designed to ping a DNS server to retrieve an IP. A typical Bash Script is used to automate monotonous tasks like scanning folders and deleting automatically backed up files, or setting permissions to new files.
How do you make a Bash Script?
To begin the coding of a Bash Script, all one needs is a text editor (such as Gedit). Head the file off with: <source lang="bash">#!/bin/bash</source>. Then one would write the commands or arguments that need to be performed, such as: <source lang="bash">alias nmp="nmap -vv -T Insane -P0 -O"</source> That example makes a script that eases the use of the Nmap Port Scanner. The finished product would look something like: <source lang="bash">
- !/bin/bash
alias nmp="nmap -vv -T Insane -P0 -O" </source>