Delete new line characters from a file

Hi,

I have a file with about 25 colums separated with '~', but few of the lines have extra tabs ('^') and new line characters ('$'). Is there a way I can delete those characters if they are anywhere before the 25th column in a line?

example:

CLUB000650;12345678;0087788667;NOOP MEMBER                   ;Sam          ;Sam         ;31 bridge Rd.$
ABCD00001111;PQRS20393343;0088518295;NORTH AMERICAN DIRECTORY SERV.;TATE;HELLO;123 MAIN STREET;;;LOVELAND;CO;80538;Tate  HELLO                ;11 STREET^I       ;                              ;                              ;LOVELAND                      ;CO;80538         ;N TON 00477      ;                                                  ;BLK 9K #C90A FHP MEDIA  ;S1741721;2005-06-08 00:00:00;135;1;119.52;0$

Thanks

Well, I don't even a single "~" character in your file !

The "^" is a "caret". It is not the same as a tab character.

tyler_durden

as far as i understood you want to remove spaces or tabs from the beginning or end of each field, right? if so try this:

awk -F\; '{for(i=1;i<=NF;i++) gsub("^[ \t]*|[ \t]*$","",$i)}1' OFS=\; infile

ps: i havent seen tabs in your inputfile, only spaces, thats why i put spaces in gsub part.

sorry, my delimeter is ";" , not sure what I was thinking while typing that earlier.

Thanks

use double backslashes to get rid of $ at the end and ^

awk -F\; '{for(i=1;i<=NF;i++) gsub("^[ \t]*|[ \t]*$|\\^|\\$$","",$i)}1' OFS=\; infile