bash command shell
A rich command line interface invoked by bash
Bash stands for Bourne Again SHell which is a pun on "born-again-Christians".
Basics are covered here.
uses the operators
std-output 1 and std-error-output 2
simplest use case
ls > dirlist.txt
is an abbreviation because 1 > can be shortened to >
Similarly 0 < can be shortened, omitting the 0 standing for the std-input filedescriptor /dev/fd/0 .
full feature use
ls 1 > dirlist.txt 2 > errlist.txt
The ls command produces 2 separate streams thereby easing the parsing of formatted standard output uninterrupted by error messages breaking the format. Omitting the 2 > business will make you see any err msg on the screen, i.e. unredirected away from the console device. Keep in mind that both streams are always produced by ls but they may be empty, as in the case of no error occurring at all.
If you think that typing out is too tedious, you can shorten it to
ls 1 > dirlist.txt 2>&1
doing the exact same thing. It means: "put the error stream 2 to the same place as stream 1, which is the dirlist file on the hard drive". But other than saving a few keystrokes this use of syntax achieves nothing. It makes your scripts harder to read, though, which is "un- ish".
The 1 > 2 > business applies to many commands in /bin and /usr/bin , such as "/usr/bin/find" but not all (e.g. "/usr/bin/passwd" does not work this way).
file descriptors /dev/fd/1 i.e. "std output"
/dev/fd/0 is standard input, i.e. normally the keyboard typing.
let us make use of redirection:
wall <<< HelloThisIsAwallTest
saves you the bother of creating a text file as input for wall ( = write to all).
GNU provides further examples but unlike they start with the cryptic ones and hardly ever give a simple plain example.
Practising redirection is quick to do using mc.
Ubuntu references on bash:
<https://help.ubuntu.com/community/CommandlineHowto> - intro 101
<https://help.ubuntu.com/community/AdvancedCommandlineHowto> - adv. CLI how to
GNU offers a manual, but their style of explaining is somewhat cryptic and lacks examples - unlike .
<https://www.gnu.org/software/bash/manual/bashref.html#Indexes> - bash manual by GNU