[NTLUG:Discuss] Shell script help

. Daniel xdesign at hotmail.com
Fri May 12 09:06:54 CDT 2006


Okay, so I have found that my script failure is somewhere unexpected.

I have attached the actual working script and the debug.out file.  For some 
reason, the code I added to test if the pathlist is to a file or not, 
thinks it's not a file.  Any ideas?  I'll also try the opposite approach of 
checking to see if it's a directory and if not, perform the conversion to 
see how that goes...


>. Daniel wrote:
>     >Your technique is very interesting but incredily cryptic.
>     >How does that work??
>
>It's something that the Shell does in the evaluation/expansion of
>its variables.  Do a 'man bash' and search for the section entitled
>'VARIABLE EXPANSION'.
>
>     echo ${a%/[^/]*}
>
>This says echo the following argument.  The argument is a shell variable
>$a or ${a} -- they mean the same thing.  The stuff after the percent sign
>is a regular expression which means a slash followed by any number of
>characters, zero or more, EXCEPT there can be no slashes '/'.  The percent
>sign means remove the smallest possible match of this at the tail end of
>the value of the variable 'a'.
>
>     >It works, but HOW?
>
>He he he... it's a shell game [pun intended]. :-D
>The nice thing is that the 'dirname' program doesn't need to started
>which can save you a bundle of time if this expression is inside a
>loop of some kind.
>
>     >Anyway, both methods are working... well except for one glitch:
>     >
>     >I'm a WEIRD user in that I often work with filenames in other
>     >languages...  in my case, Japanese.  So if a filename is in
>     >Japanese, it breaks this somehow.  It breaks both methods.
>     >
>     >No, scratch that... they both work from the command-line...
>     >it must be something else... now I have to figure out what's 
breaking!
>
>I can't think of a case where it wouldn't but /bin/sh should be /bin/bash,
>or linked that way.
>
>Let me know if I help with any more shell questions.
>
>	-Rusty-
>--
>    _____        Rusty Haddock  =  KD4WLZ  =  rusty at fe2o3.lonestar.org
>|\/   o \   o  **Out yonder in the Van Alstyne (TX) Metropolitan Area**
>|   (  -<  O o              Microsoft is to software what
>|/\__V__/                  McDonalds is to gourmet cooking



More information about the Discuss mailing list