Shell Step by Step (3)--stdin & If

Source: Internet
Author: User
Tags locale sorts stdin

4. Input and output

#! /bin/bash# Read users input and then get his nameread"Please input your first name: " firstNameread"Please input your last name: " lastNameecho-e"Your full name is:   $firstName  $lastName"

Read how to use:

read[-ers][-a 数组][-d 分隔符][-i 缓冲区文字]      [-n 读取字符数][-N 读取字符数][-p 提示符]      [-t 超时][-u 文件描写叙述符][名称 ...]

5. Conditional discriminant Formula

- eIs there a-nt (newer than) file1 is better than file2 new-ot (older than) file1 than file2 old-neIndicates not equal to-eqEquals, as:if["$a" -eq "$b"]-neNot equal to, as:if["$a" -ne "$b"]-GTGreater than, as:if["$a" -GT "$b"]-ge is greater than or equal to, such as:if["$a"-ge"$b"]-ltLess than, such as:if["$a" -lt "$b"]-le less than equals, such as:if["$a"-le"$b"]< is less than (requires double brackets), such as: (("$a"<"$b") <= is less than or equal (requires double brackets), such as: (("$a"<="$b") > Greater than (requires double brackets), such as: (("$a">"$b") >= is greater than or equal to (requires double brackets), such as: (("$a">="$b")-Z (zero)
[-AFILE] SupposeFILEThe existence is true. [-BFILE] SupposeFILEExists and is a block special file is true. [-CFILE] SupposeFILEexists and is a word special file is true. [-DFILE] SupposeFILEexists and is a folder is true. [-EFILE] SupposeFILEThe existence is true.

[-F file ] assumes that file exists and is a normal file true.

[-G file ] assumes that FILE exists and that Sgid is set to true. [-H file ] assumes that file exists and is a symbolic connection true.

[-K file ] is true if file exists and the sticky bit has been set. [-P FILE ] assumes that file exists and is a name pipe (f assumes O) is true.

[-R file ] is true if file exists and is readable. [-S file ] assumes that file exists and the size is not 0 true. [-T FD] assumes that the file Description descriptor FD is open and pointing to a terminal is true. [-U FILE ] assumes that file exists and that suid (set user ID) is true. [-W file ] assumes that file is true if file exists and is writable.

[-X FILE ] is true if file exists and is operational.

[-O FILE ] assumes that file exists and is valid user ID is true. [-G file ] is true if file exists and is a valid user group. [-L file ] assumes that file exists and is a symbolic connection true.

[-N file ] assumes that the FILE exists and has been MoD assumes that the IED since it is last read is true. [-S file ] assumes that file exists and is a socket true.

[File1-nt FILE2] assumes FILE1 have been changed more recently than FILE2,orSuppose FILE1 exists andFILE2does  notIs true. [File1-ot FILE2] assumes FILE1 is older than FILE2, or FILE2 exists and FILE1 does not exist.

[File1-ef FILE2] assumes that FILE1 and FILE2 point to the same device and the node number is true. [-O Optionname] assumes that the shell option "Optionname" is turned on for true. [-Z STRING] "STRING" is true if the length is zero. [-N STRING] or [STRING] The length of "STRING" is not 0 Non-zero is true. [STRING1 = = STRING2] Assume that 2 strings are the same. "=" May is used instead of "= = " for strict POSIX Complianc E is true. [STRING1! = STRING2] assumes that the string is not equal to true.

[STRING1 < STRING2] assumes "STRING1" sorts before "STRING2" lexicographically in c1> The current locale is true.

[STRING1 > STRING2] assumes "STRING1" sorts After"STRING2" lexicographicallyinch theThe current locale is true. [ARG1 OP ARG2] "OP" isOne of-eq,-ne,-lt,-le,-GTor-ge. These arithmetic binary operatorsreturn true if"ARG1" is Equal to, not Equal to,Less than, less thanor Equal to,Greater than,or Greater than or Equal to"ARG2", respectively. "ARG1" and"ARG2" is integers.

e.g:

if"$UID"-ne"$ROOT_UID" ]  then ……

Top Picks

  • LNMP Environment Construction--nginx Chapter

  • Configuring the local Yum source in RHEL6.5

  • Installation and use of Zabbix under Ubuntu

  • MySQL Dual master hot standby problem processing

  • Rsync Sync error Handling
  • Fix Elementary Boot Screen (Plymouth)
    After installing Nvidia Drivers
  • LNMP Environment Construction--mysql Chapter
  • Shell Step by Step (3)--stdin & IF
  • Shell Step by Step (4)--cron & Echo

Copyright notice: This article Bo Master original article, blog, without consent may not reprint |copyright©2011-2015, Kallen Ding, All rights Reserved.

Shell Step by Step (3)--stdin &amp; If

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.