Linux commands (use of the While,shell parameter)

Source: Internet
Author: User

#!/bin/bash while ifs=: Read name1 name2 name3 name4 #IFS是从文件读取内容时指定的分割符号, assign the contents of a to the corresponding variable in separate sections. Do echo $name 1 ' | ' $name 2 ' | ' $name 3 ' | ' $name 4 done <a #反引号与 $ () is a command replacement that executes a string in an anti-quote or $ () as a command, but cannot continue to have anti-quotes in the anti-quotes, and $ (  ) can have.  ls= ' ls ' echo $LS #单引号完全不解析命令, ignoring all special strings and outputting them as strings.  ls= ' ls ' echo $LS #双引号作用与单引号相似, the difference is that it is not so strict that there are 3 special characters in double quotes that cannot be ignored: $,\, ', that is, single quotes will interpret the special meaning of the string, while single quotes are used directly.  The ls= "LS" echo $LS #不过如果使用eval命令, allowing the commands in the double quotation marks to be interpreted.    ls= "ls" eval "$LS" set--1 2 3 4 #设置参数, the same as the 2 parameters in main C.  While [$#-GT 0] # $ #代表参数总数 do echo $ #输出第一个参数 shift 1 #将参数个数减1, and all move to 1 one bit, you can also set 2, move 2 bits at a time, equivalent to I--, i is the total number of parameters.  Done #-gt greater than #-lt less than #-ge equals #-le less than or equal to #-eq equals #-ne is not equal to #在脚本里面可以用 $1,$2 ... to accept parameters, but there is another way to accept parameters, which is getopts.          While getopts ABC opt #./main.sh-a-b-c can specify parameters and execute the relevant command do case $opt in a) echo "ABCD"        ;;          b) echo "1234";;          c) echo "ABCD";;      *) echo "* * * *";  EsacDone   

Linux commands (use of the While,shell parameter)

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.