Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know there is a man page describing available file conditions on *nix systems. What is that man page?

http://en.wikibooks.org/wiki/Bourne_Shell_Scripting/Control_flow#Test:_evaluating_conditions

The link above contains a section of file conditions. This is the information I am looking for on my system.

share|improve this question
    
Not sure why the downvotes, this is a legitimate question, and I think the test man page is not an obvious one I would find, especially when the description is "condition evaluation utility" –  Derek Jan 17 '13 at 15:44
    
Hi Derek! I'll take a guess and say this question was downvoted because it's simply a matter of reading the manual. Basically, you were looking at a page that explains how to use the test command, and you didn't look at man test—that's what's meant by "research effort", shown in the tooltip at the down vote button. In the future, please don't flag for moderator attention though for such minor things. These should be used for exceptions, but down votes happen all the time, and if you seek further advice from the community, drop a question in Super User Chat or possibly Meta Super User. Hope that helped! –  slhck Jan 17 '13 at 16:03
    
That's actually incorrect. What i was looking for is what man page to look up. In other words, I needed to know that "test" is the man page I was looking for. –  Derek Jan 17 '13 at 19:41
    
Well, take a look at the link you posted: > There is a tool for exactly this purpose called test, so you wanted the manpage for that. –  slhck Jan 17 '13 at 19:59

2 Answers 2

up vote 4 down vote accepted

The man page I usually refer to for this is test(1).

share|improve this answer
    
For the OP: Note that test and [ are often the same. –  Hennes Jan 17 '13 at 15:40
    
Wow - thanks..this is exactly what I was looking for. –  Derek Jan 17 '13 at 15:43

It's in man bash.

Here is a cross-section:

Conditional Expressions

Conditional expressions are used by the [[ compound command and the test and [ builtin commands to test file attributes and perform string and arithmetic comparisons. Expressions are formed from the following unary or binary primaries. If any file argument to one of the primaries is of the form /dev/fd/n, then file descriptor n is checked. If the file argument to one of the primaries is one of /dev/stdin, /dev/stdout, or /dev/stderr, file descriptor 0, 1, or 2, respectively, is checked.

Unless otherwise specified, primaries that operate on files follow symbolic links and operate on the target of the link, rather than the link itself.

When used with [[, The < and > operators sort lexicographically using the current locale.

-a file
True if file exists.
-b file
True if file exists and is a block special file.
-c file
True if file exists and is a character special file.
-d file
True if file exists and is a directory.
-e file
True if file exists.
-f file
True if file exists and is a regular file.
-g file
True if file exists and is set-group-id.
-h file
True if file exists and is a symbolic link.
...

Another option for just the evaluations is man test which is just the conditions.

share|improve this answer
    
Are those supposed to apply across all shells? I am using bourne shell. –  Derek Jan 17 '13 at 15:23
    
There are probably lots of similarities, but other shells may have other options. Are you in Bourne or Bourne Again? –  nerdwaller Jan 17 '13 at 15:25
    
I am in bourne shell. I know there is a specific man page for file conditions without having to wade through the rest of the man page for the shell, because I was on it at one point, but lost my history and can't remember it. –  Derek Jan 17 '13 at 15:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.