Linuxshell programming-shell judgment

Source: Internet
Author: User
Linuxshell programming ---- judge 1test in shell to judge 1test-f $ file name to determine whether the file exists test-f $ file name. example: use the test-f command to find whether inputtxt exists in the home. if exist is output, otherwise, output no Linux shell programming ---- judge 1 test in shell to Judge 1 test-f $ file name to determine whether the file exists test-f $ file name. example: use the test-f command to find the input.txt file in the/homedrop folder, if exist is output, otherwise, no exist 2 is output, and there are many other commands: 1 test-d $. the directory name determines whether the directory exists. 2 test-r $ the file name determines whether the file has the read permission. 3 test-w $ the file name determines. whether the file has the write permission 4 test-x $ whether the file has the execution permission 2 [[Judge 1 must be separated by spaces in brackets, for example, ['10' <'20'] In this way, it is best to have four spaces in brackets. 2. variables in brackets, it is best to enclose a = "this" B = "this is" in double quotes, for example, ["$ "! = "$ B"] 3 constant in brackets, it is best to enclose them in single quotes, for example, ['4' = '4'] 3 (The following is just an example of [], or test, only [] looks beautiful) 1. single branch judgment structure if []; then statement fi 2 dual branch judgment structure if []; then statement else statement fi 3 multi-branch judgment structure if []; then statement elif []; then statement else statement fi 4 case realize multi-branch judgment structure case $ Variable in condition 1) statement; condition 2) statement; condition 3) statement ;;............................. *) statement; esac
Related Article

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.