Control of shell command execution sequence

Source: Internet
Author: User

Shell Command Execution Sequence Control [plain] www.2cto.com & command 1 & command 2: If this command is successfully executed, execute this command. [Development]/usr/xxxx/ytcclb> ls-l test. SQL-rwxr -- r -- 1 xxxx group 225 Nov 15 test. SQL [development]/usr/xxxx/ytcclb> cp test. SQL test. bak & echo "coping file OK! "Coping file OK! [Development]/usr/xxxx/ytcclb> ls-l test. *-rwxr -- r -- 1 xxxx group 225 Nov 15 17: 48 test. bak-rwxr -- r -- 1 xxxx group 225 Nov 15 test. move the SQL file and delete the Directory: $ mv/apps/bin/apps/dev/bin & rm-r/apps/bin to sort the file and output it to another file, print: $ sort test. SQL> test. bak & lp test. bak | command 1 | command 2: If this command fails to be executed | then run this command. $ Cp test. SQL test. bak | echo "errors occured during coping file" For example: [development]/usr/xxxx/ytcclb> cp test. SQL test. bak [development]/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 [development]/usr/xxxx/ytcclb> chmod u-w test. bak [development]/usr/xxxx/ytcclb> ls-l test. *-r-xr -- r -- 1 xxxx group 225 Nov 15 18:08 test. bak-rwxr -- r -- 1 xxxx group 225 N Ov 15 test. SQL [development]/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 [developer]/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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.