The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Whats Telnet for? epic.admin UNIX for Dummies Questions & Answers 16 07-02-2006 04:09 AM
Whats Behind Your Name? google What's on Your Mind? 66 10-18-2005 08:40 PM
Whats the go? Neo Post Here to Contact Site Administrators and Moderators 1 10-01-2004 12:52 PM
Whats does this mean jyotipg Shell Programming and Scripting 1 04-06-2004 08:11 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-30-2008
Arunprasad Arunprasad is offline
Registered User
  
 

Join Date: Aug 2008
Location: syn chen
Posts: 73
Post whats this NAME=${0##*/}

hi all,

i found NAME=${0##*/} in a script.
i given this coomand in my unix box(presently in ksh).

echo ${0##*/} it returned ksh.
the purpose of the above is to return the shell name or more than that.

do you have any more information like this, please share with me.

one more query
what is set -xv and +xv.
i read the above with "man". but i am not clear with that.
  #2 (permalink)  
Old 09-30-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,886
I guess as they say, RTFM more carefully. Just kidding.

NAME=${0##*/}
simply gets the name of the currently executing script. The $0 is what does it, and the rest strips of the leading path names. It's useful when the script name is supposed to different things depending on how its invoked. For instance, if you have a softlink to your script named "foo" and another softlink named "bar", then your script can do print out "FU" instead of "Beyond All Recognition". Or something.

set -xv +xv are shorthand for
Code:
set -x
set -v
The first turns on "eXecution debugging". Every command that is executed, and after parsing, is printed to stderr. The second turns on "Verbose mode" which prints to stderr every line that is read in and before being parsed, whether or not it is executed.
  #3 (permalink)  
Old 09-30-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,886
I guess as they say, RTFM more carefully. Just kidding.

NAME=${0##*/}
simply gets the name of the currently executing script. The $0 is what does it, and the rest strips of the leading path names. It's useful when the script name is supposed to different things depending on how its invoked. For instance, if you have a softlink to your script named "foo" and another softlink named "bar", then your script can do print out "FU" instead of "Beyond All Recognition". Or something.

set -xv +xv are shorthand for
Code:
set -x
set -v
The first turns on "eXecution debugging". Every command that is executed, and after parsing, is printed to stderr. The second turns on "Verbose mode" which prints to stderr every line that is read in and before being parsed, whether or not it is executed.
  #4 (permalink)  
Old 10-01-2008
broli's Avatar
broli broli is offline
Registered User
  
 

Join Date: Dec 2007
Location: Argentina
Posts: 215
NAME=${0##*/} is a fancy awy of doing "basename $0"
$0 is a special variable that hold the name of the script (or if you doit in a loguin shell, the name of the shell), including the full path to the executable
the other ##, well, is complicated and must admit i dont know why it works, to advanced for me
if you want, you can read the "basename" man page to get a grasp of what it does
  #5 (permalink)  
Old 10-02-2008
Arunprasad Arunprasad is offline
Registered User
  
 

Join Date: Aug 2008
Location: syn chen
Posts: 73
yeah Broli,
i do it.

Thanks for your update
  #6 (permalink)  
Old 10-02-2008
Arunprasad Arunprasad is offline
Registered User
  
 

Join Date: Aug 2008
Location: syn chen
Posts: 73
iam using ksh, i doesn't find in man page for basename about ##.
  #7 (permalink)  
Old 10-02-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
No, ## is described in the man page for the shell. The basename command is just a different way to do this particular substitution.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0