![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Use wildcards in a script | emferrari | Shell Programming and Scripting | 13 | 03-07-2008 04:14 AM |
| wildcards NOT | C3000 | UNIX for Dummies Questions & Answers | 5 | 11-21-2007 07:19 AM |
| Wildcards in SED | HealthyGuy | Shell Programming and Scripting | 5 | 09-27-2006 08:32 PM |
| ls with wildcards | benu302000 | UNIX for Dummies Questions & Answers | 10 | 06-29-2005 02:53 PM |
| wildcards | benu302000 | UNIX for Dummies Questions & Answers | 3 | 06-29-2005 01:10 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I'm trying to delete lines from a large text file using VI.
Every line that I am wanting to delete start with 'S' - all others do not. (A list of users) I've tried using * but doesn't seem to like it...any ideas... Doesn't have to be VI - but I'm better with VI than sed/awk. |
|
||||
|
Ah...ooops...there are some that do start with S....
But all those that start with S[0-9] should be removed - those that start S[A-Z] should remain. Also another way might be looking for any rows with [0-9] appearing in them anywhere - as these too will satisfy the criteria. ..... ![]() |
|
|||||
|
D'oh!
I saw this message in another thread from J.P.: Quote:
![]() |
|
|||||
|
Quote:
:g/.*[0-9].*/d Similar to the above, it will remove any line with a number embedded in there... |
|
||||
|
Cool.... the answer I was looking for was how to use the wildcard ....which I can see is used by preceeding with a dot.
The rest is a peice of cake...and yeah - I did it with the numbers only - which became apparent as I worked through it. Thanks all. |
|
|||||
|
Pete,
If you want to delete a specific recurring pattern at the beginning of the line you can use the "^". Or use the $ for patterns at the end of the line. :g /^S[0-9]/d This will work for deleting lines that begin that way. ![]() |
![]() |
| Bookmarks |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|