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
Embedding Perl construct in ksh... svetlur Shell Programming and Scripting 1 06-07-2007 09:39 PM
Problem with looping construct mikie Shell Programming and Scripting 6 09-07-2006 08:48 AM
extracting info from Unix database to construct a visual diagram fusion99 UNIX for Advanced & Expert Users 0 11-30-2004 01:29 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-27-2007
ajcannon ajcannon is offline
Registered User
  
 

Join Date: Aug 2007
Location: Binfield, Berkshire. UK
Posts: 91
ksh construct

Hi Guys,

could someone tell me what this ksh construct does

typeset -r PROG_PWD=${0%/*} does

I understand the -r for readonly but I would very much appreciate a definitive account of what this will set $PROG_PWD to.

If I run this at the cmd line it it gets set to /usr/bin but I would like to know .....why?

cheers
  #2 (permalink)  
Old 09-27-2007
ajcannon ajcannon is offline
Registered User
  
 

Join Date: Aug 2007
Location: Binfield, Berkshire. UK
Posts: 91
typo

sorry - there is an extra 'does' in the post...

ignore the one on the 'typeset' line

cheers
  #3 (permalink)  
Old 09-27-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
From the ksh man page:

Code:
${parameter%word}       Remove Smallest Suffix Pattern.  The
                             word   is   expanded  to  produce  a
                             pattern.  The  parameter   expansion
                             then  results in parameter, with the
                             smallest  portion  of   the   suffix
                             matched by the pattern deleted.
Suppose $0 is /usr/bin/ksh, then ${0%/*} means that the /* is expanded to /ksh - this is the smallest pattern that you can get, and it is deleted. If you had %%/*, it would be the largest match to the pattern, which would mean /usr/bin/ksh (the output would be nothing).
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 12:55 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