Give it a bash
The Bourne Again Shell, that is.
As a Linux user, it's really quite handy to know how to do some basic shell scripting. These are little combinations of shell commands that you can save in a file, and have the computer run them just like a program. Anyone who remembers DOS batch (*.bat) files will know what I mean, except that in comparison, shell scripts are like supercharged, steroid-pumped batch files.
Shell scripts are an extension of the power of the command line to chain together commands.
Take for instance this little number:
This lists all the modules loaded by the Linux Kernel, searches ('greps') through the list for any module having 'snd' as part of its name and outputs the results to a new text file named 'sound_modules.txt' in the current directory. All done in one line.
A shell script is a sequence of such commands, grouped together in a file that can be run just like a program.
Imagine, then, being able to automatically generate HTML pages with system information in it. Or being able to compile a log of users' accesses to certain directories, then sort them by user group, saving the results to a remote location automatically at a certain time of day, every day except Sundays. Or batch renaming of thousands of your automatically generated reports. All this and more can be yours.
If this kind of thing gets you salivating, check out William Shotts Jr's Linux Command website. It has a fantastic, easy-to-digest, gentle, but actually useful introduction to shell scripting.
There are probably two or three shells hidden away in a corner of your Unix-like Operating System - even Apple owners can join in, since OsX is of pedigree Unix lineage.
As a Linux user, it's really quite handy to know how to do some basic shell scripting. These are little combinations of shell commands that you can save in a file, and have the computer run them just like a program. Anyone who remembers DOS batch (*.bat) files will know what I mean, except that in comparison, shell scripts are like supercharged, steroid-pumped batch files.
Shell scripts are an extension of the power of the command line to chain together commands.
Take for instance this little number:
[user@linuxbox home]$ lsmod | grep snd > sound_modules.txt
This lists all the modules loaded by the Linux Kernel, searches ('greps') through the list for any module having 'snd' as part of its name and outputs the results to a new text file named 'sound_modules.txt' in the current directory. All done in one line.
A shell script is a sequence of such commands, grouped together in a file that can be run just like a program.
Imagine, then, being able to automatically generate HTML pages with system information in it. Or being able to compile a log of users' accesses to certain directories, then sort them by user group, saving the results to a remote location automatically at a certain time of day, every day except Sundays. Or batch renaming of thousands of your automatically generated reports. All this and more can be yours.
If this kind of thing gets you salivating, check out William Shotts Jr's Linux Command website. It has a fantastic, easy-to-digest, gentle, but actually useful introduction to shell scripting.
There are probably two or three shells hidden away in a corner of your Unix-like Operating System - even Apple owners can join in, since OsX is of pedigree Unix lineage.
"Do not underestimate the power of the bash script."
- D. Vader
A shell is the text-based interface between a user and the operating system, sometimes called the Command Line Interface or Command Line. Think 'DOS prompt' or 'cmd.exe', but imagine them having useful features like Tab-completion, command history, and colour!
[Back]
0 Comments:
Post a Comment
<< Home