The UNIX and Linux Forums  

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
Linux Shell Question: how to print the shell script name ? meili100 UNIX for Dummies Questions & Answers 3 07-01-2008 02:55 PM
#!/bin/sh shell question GCTEII Shell Programming and Scripting 0 02-23-2006 03:08 AM
AWK question in the KORN shell penfold Shell Programming and Scripting 11 02-09-2005 09:14 AM
Question about Korn Shell Latha Nair Shell Programming and Scripting 13 11-05-2003 07:30 AM
Shell question anjanb2 UNIX for Dummies Questions & Answers 5 07-03-2002 01:00 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 06-03-2007
convenientstore convenientstore is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 42
shell question

Can someone please explain the PS1="${x##*/}\$ " ??

how does that lop off leading components?

I don't understand it.. thanks

cd ( ) {

command cd "$@" Actually change directory

x=$(pwd) Get current directory name into variable x

PS1="${x##*/}\$ " Lop off leading components, assign to PS1

}
  #2 (permalink)  
Old 06-03-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
Extract from bash man pages :
Quote:
${parameter##word}
The word is expanded to produce a pattern just as in pathname expansion. If
the pattern matches the beginning of the value of parameter, then the result
of the expansion is the expanded value of parameter with the shortest match-
ing pattern (the ``#'' case) or the longest matching pattern (the ``##''
case) deleted. If parameter is @ or *, the pattern removal operation is
applied to each positional parameter in turn, and the expansion is the
resultant list. If parameter is an array variable subscripted with @ or *,
the pattern removal operation is applied to each member of the array in
turn, and the expansion is the resultant list.
An example :

Code:
$ var=/a/b/c/d
$ echo ${var##*/}
d
$

Jean-Pierre.
  #3 (permalink)  
Old 06-03-2007
convenientstore convenientstore is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 42
how do u find these things?

that's great.. thank you so much
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 04:57 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