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
please explain the below mail2sant Shell Programming and Scripting 1 04-04-2008 08:04 AM
please explain this dummy_needhelp Shell Programming and Scripting 2 10-15-2007 01:17 AM
Can anyone explain plz r_W213 UNIX for Advanced & Expert Users 3 03-27-2007 04:52 AM
if [ $? -eq 0 ] .. can someone explain this? ranjita.c Shell Programming and Scripting 5 10-03-2006 07:50 PM
Explain awk hitmansilentass Shell Programming and Scripting 4 09-27-2006 02:14 PM

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

Join Date: Apr 2008
Posts: 1
Please can any one explain this ${0##/}

I did not understand what is ${0##/}

PGM=${0##/}
TMP=/tmp/${PGM}.$$


Please explain me.
  #2 (permalink)  
Old 04-01-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
'man ksh' yields the following:
Code:
       ${name#pattern}, ${name##pattern}
              If pattern matches the beginning of the value of parameter name,
              the  matched text is deleted from the result of substitution.  A
              single # results in the shortest match, two #'s results  in  the
              longest match.

       ${name%pattern}, ${name%%pattern}
              Like  ${..#..}  substitution, but it deletes from the end of the
              value.
  #3 (permalink)  
Old 04-01-2008
unilover unilover is offline
Registered User
  
 

Join Date: Mar 2008
Location: Toronto, Canada
Posts: 66
PGM=${0##/}
TMP=/tmp/${PGM}.$$

$0 is the complete-name-of-the-script in side the script (e.g. /home/mydir/myscript.sh)

So, ${0##/} means the complete-name-of-the-script without the starting-slash (if it exists)!!

But, what I thing you wanted to write is:

PGM=${0##*/}

which means complete-name-of-the-script without everthing up to and including the last-slash (e.g. myscript.sh)

Then, $$ is the Process-ID of the current script. So, TMP will be set to be /tmp/myscript.sh.1234 (where 1234 is the process-id).

This combination is normally used to create unique (i.e. different for each running script) names.
Sponsored Links
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 06:51 AM.


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