File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes this= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "this="${0##*/}"" Watch "this="${0##*/}"" New topic
Author

this="${0##*/}"

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
hello

i read a kshell script, find a line as---this="${0##*/}"

in the beginning part of the script, i have check the document, and can't figure out what on earth it mean,please help me.


thank you
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

Have you tried typing it into a shell and seeing what it does? Remember, a shell script is just a series of commands. When I do it in a Cygwin Bash shell, I get the name of the shell:

Another clue is how the variable is used from then on? Is it compared to values? Used in calculations?


[How To Ask Questions On JavaRanch]
zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
yes, you are right, in the script, it used to get the script name. but what i feel stranged is the content---0##*/, what is it? it is not a unix command and i can't find it from kshell document, so it is not the syntax of kshell, originally, it seem like the regular expression. but it is not.

WHAT ON EARTH IS IT?

thanks
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

It's the shell syntax for parameter substitution.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Wow. If I typed words like that, I'd get my mouth washed out with soap.

Seriously, it's an interesting little critter that runs a regular expression on a shell parameter. Here's a snipper from the ksh man page:


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: this="${0##*/}"