In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
1. Judge according to the "file type" (whether it exists or not)
-e: does the "file" exist? Existence is true (commonly used)
-f: is the "file" a normal file (file)? (commonly used)
-d: is the "file" a directory file (directory)? (commonly used)
-b: is the file a block device file (block devic)? Device
-c: is the "file" a character device file (character device)? Device
-s: change the "file" to non-empty?
S: is the "file" a socket file (Socket)? File
-p: is the "file" a pipe file FIFO (pipe)? File
L: is the "file" a symbolic link file? File
Two kinds of judgment format
Case study:
[root@root /] # cd mnt/ [root@root mnt] # ls abc.txt [root@root /] # test-e / mnt/abc.txt / * verify that the file has * / [root@root /] # echo $? / * verify that the previous command is output correctly. Correct is 0, error is 1 * / 0 [root@root /] # [- e / mnt/abc] / * Note. There should be a space between the parentheses and the command line * / [root@root /] # echo $? 1 but echo $? If it is troublesome, you can use the & & and | symbol to determine whether the command output is correct. As follows: [root@root /] # [- e / mnt/abc.txt] & & echo "yes" | | echo "no" yes
two。 Judge according to "file permissions" (whether it exists or not)
-r: does the file name have a "readable" attribute? (commonly used)
-w: does the file name have a "writable" attribute? (commonly used)
-x: does the file name have an "executable" attribute? (commonly used)
-u: does the file name have permission for "SUID"?
-g: does the file name have permission for "SGID"?
-k: does the file name have permission for "Sticky Bit"?
-s: is the file name "non-blank file"?
For example: check the writeable executable permissions of the file (as long as one exists in the main group)
[root@root mnt] # ls-l total dosage 0m r r w m r m el el. 1 root root October 18 01:55 123.txtmurr RWMurr Murray. 1 root root October 17 23:39 abc.txt [root@root mnt] # [root@root mnt] # [- x abc.txt] & & echo "yes" | | echo "no" no [root@root mnt] # [- w abc.txt] & & echo "yes" | echo "no" yes "
3. A comparison between two files
-nt (newer than) to determine whether file1 is newer than file2
-ot (older than) to determine whether file1 is older than file2
-ef can be used to judge whether file2 and file2 are the same file, which can be used to judge hard link. The main significance is to determine whether the two files point to the same inode number!
For example: determine whether the file abc.txt is newer than the file 123.txt
[root@root mnt] # ls-l total dosage 0m r r w m r m el el. 1 root root October 18 01:55 123.txtmurr RWMurr Murray. 1 root root October 17 23:39 abc.txt [root@root mnt] # [abc.txt-nt 123.txt] & & echo "yes" | echo "no" no
4. Judgment between integers
-eq two values are equal (equal)
-ne two numerical values are not equal (not equal)
-gt N1 is greater than N2 (greater than)
-lt N1 less than N2 (less than)
-ge N1 greater than or equal to N2 (greater than or equal)
-le N1 is less than or equal to N2 (less than or equal)
For example: whether / * 22 is equal to 23 is the output yes, not the output no*/
[root@root /] # [22-eq 23] & & echo "yes" | | echo "no" no
5. The judgment of string
-z: determine whether the string is 0? True if the string is empty.
-n: determine whether the string is not 0? False if the string is empty.
Note:-n can also be omitted
Character 1 = = character 2 determines whether character 1 is equal to character 2, and if equal, returns true
Character 1! = character 2 determines whether character 1 is not equal to character 2, and if equal, returns false
For example: judge whether the variable aa is equal to the variable bb
[root@root /] # aa=qaz / * assignment variable * / [root@root /] # bb=qaz [root@root /] # [$aa= = $bb] & & echo "yes" | | echo "no" yes
6. Multiple condition determination
-a (and) the two conditions are true at the same time and return to true.
-o (or) either case is true and returns to true.
! The logic is wrong to reverse the original judgment.
For example: assign the variable aa to determine whether the variable aa exists, and if it exists, determine whether the variable aa is equal to 30. Yes, then yes, otherwise no
[root@root /] # aa=30 [root@root /] # [- n $aa-a $aa-eq 30] & & echo "yes" | | echo "no" yes attachment: http://down.51cto.com/data/2366565
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.