Handy Linux/Unix
a Menu Page |
! Note !
More sample commands and scripts and links may be added
to these pages --- if/when I revisit or use these pages.
< Go to Table of Contents, below. >
(Skip the following Introduction.)
INTRODUCTION : Below are links to samples of shell commands and shell-script code --- grouped in several categories:
Use the table-of-contents below to go to code samples in these categories. |
Table of Contents:(links to content on this page --- or on other pages of this site)
End of Table of Contents. See notes below. |
Some code notes : Generally, in ALL my scripts, I use double-# (##) to indicate a true comment. That is, it is not an executable statement and should never be de-commented. I use single-# (#) to indicate an executable statement that has been commented. Typically this is because I might want to decomment the statement when doing testing of the script in a terminal window. Generally, the statement should be re-commented --- or a neighboring statement should be commented --- when done testing. I do not try to make one-liner scripts, nor do I try for the ultimate in processing efficiency. (But I am aware of several things to avoid that would make scripts run as slow as molasses.) Rather, I try to make the scripts readable (to me). At the same time, they generally execute quite rapidly --- as rapidly as the target files and the applications called allow, even on a directory containing more than one hundred files. Shell considerations : Most of these samples are intended to run with the Bourne or the Korn shells (command interpreters), as well as with the Bash command interpreter. Most of these samples employ commands (and their parameters) available to all three interpreters, so the scripts (and aliases) will generally run in any of these three interpreters. In fact, the Korn and Bash interpreters are offshoots of the Bourne command interpreter. Most of my scripts start with the line "#!/bin/sh". In many Linux distros (like Ubuntu), /bin/sh is a symbolic-link (aka 'soft link') back to /bin/bash or /bin/dash, where dash is basically a subset of the bash interpreter. If /bin/sh does not exist in your Linux distro, you can simply create the symbolic link by issuing (as root) the command ln -s /bin/bash /bin/sh where /bin/bash represents the location of the bash interpreter program. |
Brief BACKGROUND on shell scripting : This page assumes the reader is familiar with shell scripting. However, for a basic introduction to Linux/Unix shell scripting, try the Wikipedia page on Shell_scripting. In particular, see the Wikipedia page on the Bourne_shell. You may find it helpful to follow some links on those pages. Shell scripting TUTORIALS / REFERENCES : There are many web sites that provide tutorials for shell scripting. Someday I may provide a separate web page of such sites. Unfortunately, many such sites go dead quite rapidly. In the meantime, here are a few links to some tutorials :
A problem with tutorials is that they often contain many code 'snippets' but not many complete code samples that accomplish very much. To accomplish much, they would have to be too long for a tutorial. SOURCES of Shell Script code samples : Web Archives: Many instructive shell script code samples are available through code archive web sites such as I found the Shelldorado archive by doing a web search on 'strings' like : I used the keywords 'shell script' because there are many other scripting languages, such as Perl, Python, and Tcl/Tk. For Tcl-Tk scripts, see (old) Tcl-Tk samples pages available via the 'Tcl-Tk' section of my Computer Topics (Ref Info) page --- or see the 'tkGooies' at freedomenv.com --- or see my Tcl-Tk LINKS page available via the Home page of this site. The code samples on my script-samples pages --- such as the 'feNautilusScripts' Code Samples pages --- may be, in some cases, too large for tutorials. But they have much to offer in the way of examples of working (that is, de-bugged ... to a pretty good extent) shell scripting code for shell-script developers 'of all stripes'. SCRIPT-CODE WEB SEARCHES: Since many shell scripts start off with a call to the '#!/bin/sh' or '#!/bin/ksh' or '#!/bin/bash' interpreter, one way to find code samples is to do web searches on keyword strings such as
NOTE:
Forums: Another handy source of help and code samples for shell scripting is forums, such as Forums come and go (or just fade away), so some of these will probably be dead links. You could try a web search on 'strings' like : Books: The most practical and useful book on shell scripting that I have ever found is the O'Reilly book, 'Unix Power Tools'. If you can't find an answer to your shell scripting question in this book, you will probably have to do a web search. |
Bottom of this To return to a previously visited web page location, click on the Back button of your web browser a sufficient number of times. OR, use the History-list option of your web browser. OR ...
< Go to Table of Contents, above. >
Page history:
Page was created 2009 Oct 28.
|