[Techtalk] once again frustrated by bash :(

Kai MacTane kmactane at GothPunk.com
Tue Mar 9 15:29:33 EST 2004


At 3/9/04 02:11 PM , Angelina Carlton wrote:
>ugh, thanks guys.
>
>if ! [ -d "$1" ] ;
>
>does what need.

If you want to test for "not a directory", and you're sure that you'll only 
be dealing with directories and regular files (that is, you won't have to 
worry about pipes, symlinks, etc.), you could also use:

if [ -f "$1" ];

There are also file test operators for things like "is a symlink", "is a 
block special file", is a character special file", "is a named pipe", and 
so on. There's a whole list of bash conditional tests at:

http://www.gnu.org/software/bash/manual/bashref.html#SEC77

I've found many of those to be very useful.

                                                 --Kai MacTane
----------------------------------------------------------------------
"And when I squinted/The world seemed rose-tinted;
  Angels appeared to descend..."
                                                 --Depeche Mode,
                                                  "Waiting for the Night"



More information about the Techtalk mailing list