Computing.Net > Forums > Disk Operating System > deleting multiple lines in txt file

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

deleting multiple lines in txt file

Reply to Message Icon

Original Message
Name: postman
Date: April 6, 2005 at 10:48:23 Pacific
Subject: deleting multiple lines in txt file
OS: win2k
CPU/Ram: 500
Comment:

how to you delete multiple lines in a txt file using dos commands? these lines are all at the bottom of the txt file


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: April 6, 2005 at 11:12:38 Pacific
Reply:

If the lines are unique, let's say they look like:

one
two
three
four
five
six

You can:

find /v "six" somefile | find /v "five" > newfile

If the lines are not unique, or if you want to delete the last x number of lines regardless of content, that's different.

M2


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


Report Offensive Follow Up For Removal

Response Number 2
Name: postman
Date: April 6, 2005 at 12:05:24 Pacific
Reply:

the lines (about 3-4,000) that i need to delete are all at the end of the file and are similar to the following:
wwwyyybbhhkjhf$
;lksdflksfsf$
qweporilkjdf$
;liasdjfosaddf$
;lksadhksdf$
the common components are the lines end with $

thanks


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: April 6, 2005 at 12:25:08 Pacific
Reply:

Hi,

Do you want to do this with w2k?

[You're in the DOS forum.]

M2


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


Report Offensive Follow Up For Removal

Response Number 4
Name: postman
Date: April 6, 2005 at 12:37:51 Pacific
Reply:

yes i want to do this in dos!


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: April 6, 2005 at 12:39:33 Pacific
Reply:

OK,

Which is it, DOS or w2k?

M2


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


Report Offensive Follow Up For Removal


Response Number 6
Name: postman
Date: April 6, 2005 at 12:55:55 Pacific
Reply:

yes in DOS


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: April 6, 2005 at 13:05:16 Pacific
Reply:

There's no straightforward way that I know of to do it in DOS.

Are you willing to use a 3rd party utility?

M2


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


Report Offensive Follow Up For Removal

Response Number 8
Name: jboy
Date: April 6, 2005 at 14:25:05 Pacific
Reply:

"yes i want to do this in dos!"

You mean the Win2K command prompt don't you?

That's not actually 'DOS'

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: April 7, 2005 at 00:26:53 Pacific
Reply:

If there was any lingering doubt that a forum name change would eliminate confusion, it has now been cleared up.

M2


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


Report Offensive Follow Up For Removal

Response Number 10
Name: jboy
Date: April 7, 2005 at 09:00:26 Pacific
Reply:

"yes in DOS"

... sure it is.


Heh - doesn't seem to have made a great deal of impact. I'm always somewhat amazed that writers of complex batchfiles appear to be oblivious of the distinction

Time to break out the 'NT Command Prompt forum'??

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.


Report Offensive Follow Up For Removal

Response Number 11
Name: Mechanix2Go
Date: April 7, 2005 at 09:09:27 Pacific
Reply:

jboy,

I thought maybe DOS=denial of sanity might help.

M2


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


Report Offensive Follow Up For Removal

Response Number 12
Name: dtech10
Date: April 8, 2005 at 13:08:58 Pacific
Reply:

Hi

@echo off
type Filename.txt | find /v "$" > Newfile.txt



Report Offensive Follow Up For Removal

Response Number 13
Name: Mechanix2Go
Date: April 8, 2005 at 19:54:23 Pacific
Reply:

Hi dtech10,

Yes, but only if none of the other lines [those to keep] contain $.

***
OP has not answered #7, so I guess we're not going to find out.

M2


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


Report Offensive Follow Up For Removal

Response Number 14
Name: wizard-fred
Date: April 9, 2005 at 05:21:39 Pacific
Reply:

A common thread to all these posts. Everyone wants to do 'it' in 'DOS' or with a batch. 95% or more aren't capable of running real DOS. Most of them can be done using existing programs in whatever version of Windows they're using. Many appear to be an infrequent or singular occurrence of a 'problem'. Example this post. Just editing the file would fix yhe problem.

Those who use the command prompt have been elevated to the rank of merlin and this forum is now where the masses come to seek the magic.


Report Offensive Follow Up For Removal

Response Number 15
Name: Mechanix2Go
Date: April 9, 2005 at 05:39:07 Pacific
Reply:

Hi wizard-fred,

Yeah, some of this stuff pretty much defies comment.

There's one character with about six threads mostly about working up a list of music. Can't tell which is furthest out in the ozone. A couple folks tried to help, but it's pretty much help-resistant.

And I'm not dealing with that 'Roman Numeral' mess.

~SIGH~


M2


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


Report Offensive Follow Up For Removal






Post Locked

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


Go to Disk Operating System Forum Home



Results for: deleting multiple lines in txt file

how to delete double lines in txt?
    Summary: Friends, how to delete double lines in txt-file using DOS batch. I'm happy for a solution with a 3rd party program, as long as it runs in a DOS batch file :-) ...
www.computing.net/answers/dos/how-to-delete-double-lines-in-txt/13875.html

Delete all the lines in text file
    Summary: Hi , I want to delete all the lines in text file except the last one. Could you please help me. I am new for dos command regards Shashi...
www.computing.net/answers/dos/delete-all-the-lines-in-text-file/16767.html

Count line in a text file
    Summary: Hi every body I need to count the number of line in a file. My file is like this: |tetrte|ezrzer|||||erez| |tetrte|ezrzer|||||erez| |tetrte|ezrzer|||||erez| I found something: find /C "|" filename I a...
www.computing.net/answers/dos/count-line-in-a-text-file/14001.html






Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History






Data Recovery Software