![]() |
|
|
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. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello, I am very new to shell scripting and have a directory path such as:
/usr/dev/blah/Arch/release/812-1235-P05/files/list and I want to output: 812-1235-P05 I think using sed with a regex like [0-9]-[0-9]-[0-9]?[a-z] would be the way to go, but I am having much trouble getting it to work. Any suggestions? Thank you. |
|
||||
|
Thank you so much for your reply. Looks like it should work, I am piping
/usr/dev/blah/Arch/release/812-1235-P05/files/list which is from a previous grep command into sed so like Code:
grep command_to_get_path | sed 's/.*\([0-9]\{3\}-[0-9]\{4\}-[0-9A-Z]\{3\}\).*/\1/'
Thanks again! |
|
|||||
|
That is strange, if I pipe that string directly into sed on my machine I get the required result. Can you run the grep without the sed and show us the exact output of the grep (including all spacing and 'wierd' chars).
my sed version: chris@druid: ~ $ sed --version GNU sed version 4.1.5 Last edited by wempy; 10-21-2008 at 11:57 AM.. Reason: added sed version |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|