Edit text file. Remove varying end of each line.

n666

Senior member
Jan 19, 2004
356
0
0
Hey All,

I'm working with a large document in which I need to get rid of some junk at the end of each line of text.

For example:

Concerts - Alan Jackson 2006/11/07 22:17:07
Concerts - Anthrax 2007/02/13 22:01:18 2007/02/13 22:01:18

Needs to become:

Concerts - Alan Jackson
Concerts - Anthrax


something Java based would be best.

Thanks
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Will each line follow the EXACT same formatting for the start? IE... Will it always be "Concerts - Performer Name" followed by the junk? Will the data following the name always be a date/time as well?
 

lozina

Lifer
Sep 10, 2001
11,711
8
81
using java I would use regular expression, go line by line and do something like this:

(it looks for the beginning of the date with a pattern like "####/" )

edit: i have no idea why the code thing is bunching up my lines like that
 

esun

Platinum Member
Nov 12, 2001
2,214
0
0
Java? Seems awfully excessive for something like this. How about sed?

sed -i 's/ [^a-zA-Z]*$/' filename.txt

That will get rid of all non-alphabetic characters at the end of a line (that follow a space, so a song ending in a number won't be affected).