• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9313
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9313
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the shell syntax for parameter substitution.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic