Unix Shell - ksh and pattern matching

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2005 > ksh and pattern matching





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ksh and pattern matching
michaelkatsilis@yahoo.com

2005-02-28, 8:50 pm

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
>+(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
>+(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

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

test file in dir 1

Regards,


Michael

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com