The shell
Number | Abbreviation | Definition |
---|---|---|
0 | stdin | Standard command input |
1 | stdout | Standard command output |
2 | stderr | Standard command error |
All commands that process file content read from the standard input and write to the standard output.
The following example shows the standard input (bold text) and the standard output (plain text) for the cat command.
$ cat (Read from stdin)First line (Read from stdin)First line (Write to stdout)What's going on? (Read from stdin)What's going on? (Write to stdout)Control-d (Read from stdin)
The cat command takes the standard input from the keyboard and sends the standard output to the terminal window.
You can modify the default action of the standard input, standard output, and standard error within the shell by redirecting stdin, stdout, and stderr.
<
) charactercommand < filename
exrecises:
command > filename
redirect the standard output in to a file named filename
Warning
If the file in which we redirect the stdout already exist, the file will be erased.
exercise:
Instead to erase the file, we can append the stdout at the end of the file,
using >>
.
exercises:
2>
.2>>
to append to a file.quizz
squizz -c FASTA qn1.gb > qn1.fa 2>&1
Warning
2>&1 there is no spaces between >and &1
command_1 | command_2
who | wc -l
35
who is connected?
who | cut -f 1 -d ' '| sort | uniq
is bneron
is connected?
who | grep bneron
;
(semi colon).exercise:
~/DataBio/Sequences/Nucleique/qr1.gde
in fasta formatqr1.fa
QR1.FA
filesquizz -c FASTA qr1.gd > qr1.fa ; tr 'acgt' 'ACGT' < qr1.fa > QR1.FA
squizz -c FASTA qr1.gd > qr1.fa ; blastall -p blastp -d sp -i qr1.fa
what does mean finish correctly?
when a program finish it return value:
echo $?
allow to know the return value of the last command.
;
chain commands whatever is the return value
command1 && command2
command2 will be executed if and only if command1 returned zero exit status.
Warning
The exit status depends how the developer implement programs. Sometimes the developer does not follow the convention. So it's not possible to chain correctly those programs.