&&
Command 1 & command 2: If the command is successfully executed, run the command.
[Jb]/usr/xxxx/ytcclb> ls-l test. SQL
-Rwxr -- r -- 1 xxxx group 225 Nov 15 test. SQL
[Jb]/usr/xxxx/ytcclb> cp test. SQL test. bak & echo "coping file OK! "
Coping file OK!
[Jb]/usr/xxxx/ytcclb> ls-l test .*
-Rwxr -- r -- 1 xxxx group 225 Nov 15 test. bak
-Rwxr -- r -- 1 xxxx group 225 Nov 15 test. SQL
Move the file and delete the directory:
Copy codeThe Code is as follows: $ mv/apps/bin/apps/dev/bin & rm-r/apps/bin
Sort the files and output them to another file. After successful sorting, print:
Copy codeThe Code is as follows: $ sort test. SQL> test. bak & lp test. bak
|
Command 1 | command 2: If this command fails to be executed | then run this command.
Copy codeThe Code is as follows: $ cp test. SQL test. bak | echo "errors occured during coping file"
For example:
[Jb]/usr/xxxx/ytcclb> cp test. SQL test. bak
[Jb]/usr/xxxx/ytcclb> ls-l test .*
-Rwxr -- r -- 1 xxxx group 225 Nov 15 test. bak
-Rwxr -- r -- 1 xxxx group 225 Nov 15 test. SQL
[Jb]/usr/xxxx/ytcclb> chmod u-w test. bak
[Jb]/usr/xxxx/ytcclb> ls-l test .*
-R-xr -- r -- 1 xxxx group 225 Nov 15 test. bak
-Rwxr -- r -- 1 xxxx group 225 Nov 15 test. SQL
[Jb]/usr/xxxx/ytcclb> cp test. SQL test. bak | echo "errors occrued during coping file"
Cp: unable to create file test. bak: Permission denied (error 13)
Errors occrued during coping file
[Jb]/usr/xxxx/ytcclb>
() And {}: combine several commands.
(Command 1; command 2;...): execute a group of commands in the current shell.
{Command 1; command 2;...}: The content in braces is executed as a whole.