![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need a regular expression | tony3101 | Shell Programming and Scripting | 4 | 06-05-2008 04:13 AM |
| regular expression and awk | nickg | UNIX for Dummies Questions & Answers | 2 | 08-16-2007 06:23 PM |
| regular expression...help!! | andy2000 | UNIX for Dummies Questions & Answers | 6 | 07-18-2007 06:10 PM |
| help in regular expression | Rakesh Ranjan | High Level Programming | 5 | 10-25-2006 02:00 PM |
| Regular Expression + Aritmetical Expression | Z0mby | Shell Programming and Scripting | 2 | 05-21-2002 11:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Regular Expression
OK, this ones been bugging me....
9DH21AQAE~56081~109~12/18/2003~ ~B ~ ~ I want to remove all but 1 of the trailing spaces after the last ~, there may be 2 or more trailing spaces tried s/\~ +/\~ /g but no go thanks |
|
||||
|
I think that you are trying to edit the file in vi, right? Actually I don't know what result you want.
if you want the following result. 9DH21AQAE~ then :s/\~[^~]*.*$/\~/ 9DH21AQAE~56081~ then :s/\(^[^~]*\~[^~]*\~\).*$/\1/ 9DH21AQAE~56081~109~ skipped, refer to above reference 9DH21AQAE~56081~109~12/18/2003~ skipped, refer to above reference if you want to remove the last ~ 9DH21AQAE~56081~109~12/18/2003~ ~B ~ then :s/\(^.*\)\~$/\1/ |
|
||||
|
Right now I am testing in vi but eventually the replace will be put into a script.
what I want is to remove all but 1 trailing space: 9DH21AQAE~56081~109~12/18/2003~ ~B ~ ~ <space> <space> .............. to 9DH21AQAE~56081~109~12/18/2003~ ~B ~ ~<space> there will be 1 or more trailing spaces but I only ever want 1 space after the last ~ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|