![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| just want certail elements | frenchface | Shell Programming and Scripting | 1 | 05-10-2008 06:38 PM |
| Map - printing all elements - why? | dhanamurthy | High Level Programming | 0 | 04-14-2008 10:19 AM |
| To return the elements of array | Sudhakar333 | Shell Programming and Scripting | 5 | 08-06-2007 11:20 AM |
| $PWD shows absolute path vs path w/symbolic links | kornshellmaven | Shell Programming and Scripting | 3 | 06-13-2007 09:15 AM |
| vi - replacing a relative path with absolute path in a file | Yinzer955i | UNIX for Dummies Questions & Answers | 2 | 09-07-2006 08:47 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Reomve elements from a path name
I have a srcipt that I pass a path into that will consist of 5 or 6 elements (/1/2/3/4/5/6). I want to always pull the third element out of the path name. How can i do this?
Thanks |
| Forum Sponsor | ||
|
|
|
|||
|
Actually, if by "pull out" you mean "remove" rather than "extract" (as per the topic title), do as above, then glue back together all except the one you don't want. Something like
Code:
p= n= s= while true do case $# in 0) break;; esac i=$1 shift # skip $4 n=x$n case $n in xxxx) continue;; esac p="$p$s$i" s=/ done echo "$p" |
|||
| Google UNIX.COM |