Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
commands:classictest [2013/04/14 14:37]
thebonsai Don't tread version 4 special - it has been around for a long time now
commands:classictest [2015/07/30 23:01] (current)
fgrose [Table] hard link is only one example. Bind mounts are another
Line 68: Line 68:
 This section probably holds the most tests, I'll list them in some logical order. Since Bash 4.1, all tests related to permissions respect ACLs, if the underlying filesystem/​OS supports them. This section probably holds the most tests, I'll list them in some logical order. Since Bash 4.1, all tests related to permissions respect ACLs, if the underlying filesystem/​OS supports them.
  
-^Operator syntax^Description^ +^ Operator syntax ​         ^ Description ​                                                                                  |   | 
-|**-a** <​FILE>​|True if <​FILE>​ exists. :!: (not recommended,​ may collide with ''​-a''​ for ''​AND'',​ see below)| +| **-a** <​FILE> ​           | True if <​FILE>​ exists. :!: (not recommended,​ may collide with ''​-a''​ for ''​AND'',​ see below) ​ ​| ​  
-|**-e** <​FILE>​|True if <​FILE>​ exists.| +| **-e** <​FILE> ​           | True if <​FILE>​ exists. ​                                                                       ​| ​  
-|**-f** <​FILE>​|True,​ if <​FILE>​ exists and is a **regular** file.| +| **-f** <​FILE> ​           | True, if <​FILE>​ exists and is a **regular** file.                                             |   
-|**-d** <​FILE>​|True,​ if <​FILE>​ exists and is a **directory**.|| +| **-d** <​FILE> ​           | True, if <​FILE>​ exists and is a **directory**. ​                                                  ​|| 
-|**-c** <​FILE>​|True,​ if <​FILE>​ exists and is a **character special** file.| +| **-c** <​FILE> ​           | True, if <​FILE>​ exists and is a **character special** file.                                   |   
-|**-b** <​FILE>​|True,​ if <​FILE>​ exists and is a **block special** file.| +| **-b** <​FILE> ​           | True, if <​FILE>​ exists and is a **block special** file.                                       |   
-|**-p** <​FILE>​|True,​ if <​FILE>​ exists and is a **named pipe** (FIFO).| +| **-p** <​FILE> ​           | True, if <​FILE>​ exists and is a **named pipe** (FIFO). ​                                       ​| ​  
-|**-S** <​FILE>​|True,​ if <​FILE>​ exists and is a **socket** file.| +| **-S** <​FILE> ​           | True, if <​FILE>​ exists and is a **socket** file.                                              ​| ​  
-|**-L** <​FILE>​|True,​ if <​FILE>​ exists and is a **symbolic link**.| +| **-L** <​FILE> ​           | True, if <​FILE>​ exists and is a **symbolic link**. ​                                           ​| ​  
-|**-h** <​FILE>​|True,​ if <​FILE>​ exists and is a **symbolic link**.| +| **-h** <​FILE> ​           | True, if <​FILE>​ exists and is a **symbolic link**. ​                                           ​| ​  
-|**-g** <​FILE>​|True,​ if <​FILE>​ exists and has **sgid bit** set.| +| **-g** <​FILE> ​           | True, if <​FILE>​ exists and has **sgid bit** set.                                              ​| ​  
-|**-u** <​FILE>​|True,​ if <​FILE>​ exists and has **suid bit** set.| +| **-u** <​FILE> ​           | True, if <​FILE>​ exists and has **suid bit** set.                                              ​| ​  
-|**-r** <​FILE>​|True,​ if <​FILE>​ exists and is **readable**.| +| **-r** <​FILE> ​           | True, if <​FILE>​ exists and is **readable**. ​                                                  |   
-|**-w** <​FILE>​|True,​ if <​FILE>​ exists and is **writable**.| +| **-w** <​FILE> ​           | True, if <​FILE>​ exists and is **writable**. ​                                                  |   
-|**-x** <​FILE>​|True,​ if <​FILE>​ exists and is **executable**.| +| **-x** <​FILE> ​           | True, if <​FILE>​ exists and is **executable**. ​                                                |   
-|**-s** <​FILE>​|True,​ if <​FILE>​ exists and has size bigger than 0 (**not empty**).| +| **-s** <​FILE> ​           | True, if <​FILE>​ exists and has size bigger than 0 (**not empty**). ​                           ​| ​  
-|**-t** <​fd>​|True,​ if file descriptor <fd> is open and refers to a terminal.| +| **-t** <​fd> ​             | True, if file descriptor <fd> is open and refers to a terminal. ​                              |   
-|<​FILE1>​ **-nt** <​FILE2>​|True,​ if <​FILE1>​ is **newer than** <​FILE2>​ (mtime). :!:| +| <​FILE1>​ **-nt** <​FILE2> ​ | True, if <​FILE1>​ is **newer than** <​FILE2>​ (mtime). :!:                                       |   
-|<​FILE1>​ **-ot** <​FILE2>​|True,​ if <​FILE1>​ is **older than** <​FILE2>​ (mtime). :!:| +| <​FILE1>​ **-ot** <​FILE2> ​ | True, if <​FILE1>​ is **older than** <​FILE2>​ (mtime). :!:                                       |   
-|<​FILE1>​ **-ef** <​FILE2>​|True,​ if <​FILE1> ​is a **hardlink** to <​FILE2>​. :!:|+| <​FILE1>​ **-ef** <​FILE2> ​ | True, if <​FILE1> ​and <​FILE2>​ refer to the **same device and inode numbers**. :!:              ​| ​  |
  
  
Line 117: Line 117:
 | **(** <​TEST>​ **)**      | Group a test (for precedence). **Attention:​** In normal shell-usage,​ the "​("​ and "​)"​ must be escaped; use "​\("​ and "​\)"​! ​                   | | **(** <​TEST>​ **)**      | Group a test (for precedence). **Attention:​** In normal shell-usage,​ the "​("​ and "​)"​ must be escaped; use "​\("​ and "​\)"​! ​                   |
 | **-o** <​OPTION_NAME> ​   | True, if the [[internals:​shell_options| shell option]] <​OPTION_NAME>​ is set.                                                                | | **-o** <​OPTION_NAME> ​   | True, if the [[internals:​shell_options| shell option]] <​OPTION_NAME>​ is set.                                                                |
-| **-v** <​VARIABLENAME> ​  | True if the variable <​VARIABLENAME>​ has been set (since 4.2-alpha). Can't be used to determine if an array index is set, only array names.  |+| **-v** <​VARIABLENAME> ​  | True if the variable <​VARIABLENAME>​ has been set. Use ''​var[n]''​ for array elements.  |
 | **-R** <​VARIABLENAME> ​  | True if the variable <​VARIABLENAME>​ has been set and is a nameref variable (since 4.3-alpha) ​ | | **-R** <​VARIABLENAME> ​  | True if the variable <​VARIABLENAME>​ has been set and is a nameref variable (since 4.3-alpha) ​ |