Computing.Net > Forums > Programming > Remove Lines of text

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Remove Lines of text

Reply to Message Icon

Name: KS123
Date: June 9, 2009 at 19:32:04 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

Hi,

I have a sample file

First line 11111 anything
second line anything
third line anything
fourth line 2222 anything
fifth line anything
sixth line anything
seventh line 3333 anything
eightth line anything
ninth line 1111 anything
tenth line anything
eleventh line anything
twelfth line 3333 anything
thirtienth line anything
fourteenth line anything

output wanted
First line 11111 anything
second line anything
third line anything
eleventh line anything
fourth line 2222 anything
fifth line anything
sixth line anything
seventh line 3333 anything
eightth line anything
fourteenth line anything

I need to remove lines based on ####, keeping first instance line with #### along with the lines directly below until I reach the next line with ####. However, subsequent instance(s) of same #### should only include lines that are NOT the line with #### and NOT the line directly below, but any other lines after the #### line and before the next line with ####.

This needs to work in different OS batch files



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: June 9, 2009 at 20:15:57 Pacific
Reply:

i really couldn't get what you are saying. describe again, but this time don't use #### , use an actual number from your sample file. and don't write long winded english. Use examples of lines from your sample file to explain clearly.


0

Response Number 2
Name: Mechanix2Go
Date: June 10, 2009 at 06:02:50 Pacific
Reply:

"This needs to work in different OS batch files"

Which ones?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: KS123
Date: June 10, 2009 at 09:48:28 Pacific
Reply:

I want to use this for both XP and Vista and on a Windows 2003 server.

I cannot give sample file for certain reasons, but here is part of it:

Input:

H,1,,220523,20090616,,,,
D,2,1,,,,,,,220523,PART,,,,
S,3,2,,,,,00012345,,,
SD,4,3,,,,,,,,,,,,,,,
H,1,,186284,20090616,,,,
D,2,1,,,,,,,186284,PART2,,,,
S,3,2,,,,,0006789,,,
SD,4,3,,,,,,,,,,,,,,,
H,1,,186677,20090616,,,,
D,2,1,,,,,,,186677,PART3,,,,
S,3,2,,,,,000121314,,,
SD,4,3,,,,,,,,,,,,,,,
H,1,,186284,20090616,,,,
D,2,1,,,,,,,186284,PART2,,,,
S,3,2,,,,,000678910,,,
SD,4,3,,,,,,,,,,,,,,,
H,1,,186677,20090616,,,,
D,2,1,,,,,,,186677,PART3,,,,
S,3,2,,,,,00012131415,,,
SD,4,3,,,,,,,,,,,,,,,

Hoping for Output:
H,1,,220523,20090616,,,,
D,2,1,,,,,,,220523,PART,,,,
S,3,2,,,,,00012345,,,
SD,4,3,,,,,,,,,,,,,,,
H,1,,186284,20090616,,,,
D,2,1,,,,,,,186284,PART2,,,,
S,3,2,,,,,0006789,,,
SD,4,3,,,,,,,,,,,,,,,
S,3,2,,,,,000678910,,,
SD,4,3,,,,,,,,,,,,,,,
H,1,,186677,20090616,,,,
D,2,1,,,,,,,186677,PART3,,,,
S,3,2,,,,,000121314,,,
SD,4,3,,,,,,,,,,,,,,,
S,3,2,,,,,00012131415,,,
SD,4,3,,,,,,,,,,,,,,,


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Remove Lines of text

Delete first line of text www.computing.net/answers/programming/delete-first-line-of-text/13312.html

Batch to del first x lines of text www.computing.net/answers/programming/batch-to-del-first-x-lines-of-text/16887.html

swap lines of text in a text file www.computing.net/answers/programming/swap-lines-of-text-in-a-text-file/17907.html