stdout
and stderr
, and one input stream, stdin
stdin
, stdout,
and stderr
:The n in n> or n>> refers to the file descriptor. If it omitted, then standard output (file descriptor 1) is assumed.
>
and >>
redirection symbols works with stdout by default. We can use one of the numeric file descriptors to indicate which standard output stream you wish to redirect.noclobber
option of the set
builtin. use set -C for enabling noclobber:set +C
for turning globbing off.command 2>&1 >output.txt
is not the same as
command >output.txt 2>&1
Reminder: "-" A hyphen (used alone) generally signifies that input will be taken fromstdin
as opposed to a named file. try: cat - << EOF > interesting.txt
|
(pipe) operator between two commands to direct the stdout of the first to the stdin of the second. command | command
Parameter vs Argument:
Parameter is variable in the declaration of function. Argument is the actual value of this variable that gets passed to function.1Parameters2| |3function test ( param1 , param2 ){4return ( param1 + param2 );5}6test (5, 6)7| |8ArgumentsCopied!
xargs
commandfind
command with the -exec
option (previous section)If no command is specified, xargs executes echo by default.
-I
switch:it is also possible to run multiple commands with xargs
-L
option, the input will break by line and not by blanks. Other options:tail -f
to follow the output in another screen, using the tee
command is easier.-a
option It basically do not overwrite the file but append to the given file.