Monday, June 14, 2010

tcsh commands how to ...

Original source from here

cmd &
Execute cmd in background.

cmd1 ; cmd2
Command sequence; execute multiple cmds on the same line.

(cmd1 ; cmd2)
Subshell; treat cmd1 and cmd2 as a command group.

cmd1 | cmd2
Pipe; use output from cmd1 as input to cmd2.

cmd1 `cmd2`
Command substitution; run cmd2 first and use its output as arguments to cmd1.

cmd1 || cmd2
OR; execute either cmd1 or (if cmd1 fails) cmd2.

cmd1 && cmd2
AND; execute cmd1 and then (if cmd1 succeeds) cmd2.

===========================================

cmd > file Send output of cmd to file (overwrite).

cmd >! file
Same as preceding, even if noclobber is set.

cmd >> file Send output of cmd to file (append).

cmd>>! file
Same as preceding, even if noclobber is set.

cmd < file Take input for cmd from file. cmd << text Read standard input up to a line identical to text (text can be stored in a shell variable). Input usually is typed on the screen or in the shell program. Commands that typically use this syntax include cat, echo, ex, and sed. If text is enclosed in quotes, standard input will not undergo variable substitution, command substitution, etc.

===========================================

cmd >& file
Send both standard output and standard error to file.

cmd >&! file
Same as preceding, even if noclobber is set.

cmd >>& file
Append standard output and standard error to end of file.

cmd >>&! file
Same as preceding, even if noclobber is set.

cmd1 |& cmd2
Pipe standard error together with standard output.

(cmd> f1) >& f2
Send standard output to file f1 and standard error to file f2.

cmd | tee files
Send output of cmd to standard output (usually the screen) and to files. (See the example in Chapter 3, "Linux Commands" under tee.)

No comments:

Post a Comment