ksh and pattern matching

ksh and pattern matching

Post by michaelkatsi.. » Wed, 02 Mar 2005 09:08:01



Hi,

I want to run a script, I can only access the directory names listed
above (ie. in the sudo list), but I don't know which directory contains
the script (Please do not delve into the PATH variable, as this is not
what I'm after). So, what I'm after is to find out if a one liner (not
multiple lines, I've already coded this) is possible, that runs the
given script name in directories
dir1 or dir2 or dir2/subdir2

Note: f1 resides in dir2/subdir2/ and fd1 resides in dir1/

# ok, dir2/subdir2/f1 exists

Quote:>+(dir1|dir2)/*(subdir2)/f1

test file

# not ok, but dir1/f1 does exist - so why doesn't this work?
# I would have thought that this pattern is the same as
# dir1//f1, which works when executing ls dir1//f1

Quote:>+(dir1|dir2)/*(subdir1)/f1

ksh: +(dir1|dir2)/*(subdir1)/f1:  not found.

# Now, this works (without slash), but it won't for file
# +(dir1|dir2)/*(subdir1)f1

Quote:>+(dir1|dir2)/*(subdir2)fd1

test file in dir 1

Regards,

Michael

 
 
 

1. ksh pattern matching when pattern is in a variable

Witness this:


  [[ work = $exclude ]] && print excluded

The print is executed on AIX 433, but not on AIX 5.1 or SunOS 5.9.

Looking at the original AT&T ksh book by David Korn, on pg 156 under
Conditional Commands, in the [[ ... ]] section, it says

"ksh expands the operands(s) for each conditional expression primitive
for command substitution, parameter expansion, and quote removal as
required to evaluate the command."

To me, this means it should be expanding $exclude before it interprets
it as a pattern.  And this is certainaly The Right Thing To Do.  What
am I missing?

John.

2. Need help with networking & LinkSys Card

3. Pattern matching and extracting the data which matches the pattern

4. xp1000 floppy drive

5. ksh - checking for filenames matching a pattern

6. 9Gb FUJITSU disk panics Alpha box...

7. KSH Pattern Match Deletions

8. Waiting on a pthread_cond and sockets

9. ksh pattern matching

10. ksh conditional (string match pattern)

11. ksh discrepancy on pattern matching

12. How can I pattern-match in ksh?

13. my fault about pattern matching in ksh