![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Read the directory path | sollins | Shell Programming and Scripting | 1 | 11-05-2008 05:09 AM |
| Perl script variable to read shell command | bulkbiz | Shell Programming and Scripting | 4 | 10-10-2008 03:05 AM |
| Sed variable substitution when variable constructed of a directory path | alrinno | Shell Programming and Scripting | 2 | 07-11-2008 03:24 PM |
| read a path | bkan77 | Shell Programming and Scripting | 4 | 07-18-2007 03:37 PM |
| read a path | bkan77 | SUN Solaris | 2 | 07-18-2007 01:23 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
need sed command to read a path and set to variable
I have a variable called PATH that contains a path
example: /Users/rtipton/Desktop/testusers/test I need a sed command to set a variable called USER to the last directory name in that path PATH="/Users/rtipton/Desktop/testusers/test" and from that PATH i need USER to = test I know sed can do this but sed usage is still a bit of a mystery to me ![]() Thanks, Rob |
|
||||
|
Quote:
Thanks, Rob |
|
|||||
|
's/ --- Substitute directive
.*/ --- contains everything upto last / ("/Users/rtipton/Desktop/testusers/") (.*) --- contains everything after last / (test) /\1/ --- what to substitute (like $1 variable, what is inside the ( ) is stored in \1 ) there are extra \ because you have to escape metacharacters I didnt know much about sed and awk before I found this site. The way I am learning, is people ask how to do something, I read others solutions and try to replicate it. I have created my own wiki to keep all my notes in. here is one site I found helpful: http://student.northpark.edu/pemente/sed/sed1line.txt |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|