Re: [ILUG] bash script Q

From: Ronan Waide (waider at domain waider.ie)
Date: Fri 05 Apr 2002 - 19:28:45 IST


On April 5, niall at domain linux.ie said:
> The line
>
> if [[ "`file -b $file`" == PostScript\ document\ text* ]] ; then
>
> is some bash magic - [[ str1 == str2 ]] does a pattern match, and returns 1

In which case you shouldn't have #!/bin/sh, because on most unix
systems /bin/sh ain't bash. More portably, you could do the above as

if file -b $file | grep -i 'postscript document text' >/dev/null 2>&1

I think the [[ is from ksh originally. I've certainly seen it in
ksh-oriented scripts, anyway.

Waider.

-- 
waider at domain waider.ie / Yes, it /is/ very personal of me.
"If you gotta ask what it /is/ all the time, you'll never get time to /know/."
                                   - Frank Zappa


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:15:52 GMT