![]() |
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 |
| how to remove the first line from a flat file ? | xli | UNIX for Dummies Questions & Answers | 21 | 12-16-2008 01:37 AM |
| How to remove FIRST Line of huge text file on Solaris | madoatz | UNIX for Dummies Questions & Answers | 5 | 06-23-2007 01:19 PM |
| How to remove last line of the file | mani_um | Shell Programming and Scripting | 3 | 05-14-2007 08:35 AM |
| Remove header(first line) and trailer(last line) in ANY given file | madhunk | Shell Programming and Scripting | 2 | 03-13-2006 03:36 PM |
| Remove every third line from a file | bistru | Shell Programming and Scripting | 4 | 01-31-2006 07:26 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
remove a line within a file
Hi all, i have a text file similar to below
Code:
A1 A2 A3 B1 ... .... *** # first occurance B1 ... .... *** # second occurance B1 ... .... *** # third occurance Code:
B1 ... .... *** # second occurance B1 ... .... *** # third occurance I have a primitive method Code:
/cat myfile | grep B >> desired_file |
|
||||
|
Yet another alternative
You can also use csplit on the result of the grep-ped file
csplit (options) input-file-name 2 will produce two output files, one containing only the first record and the second file will contain the other stuff. Essentially you're splitting the file at line 2. Use the options to specify a prefix and/or suffix if you want. The files resulting from the csplit can be cat-ed together to recreate the file being split. Moreover, csplit leaves your input file intact. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|