[plug] Using sed to remove \n from a text file.

Buddrige, David BuddrigeD at logica.com
Thu Jul 11 11:48:31 WST 2002


Hi all,

I have a text file which contains records of data from which I want to
extract particular records.

For the most part, the records are one line each, with each successive line
being a new record.

However, some of the "records" are very long, and in this case, they have
been continued over to the next line by adding a "-" character at the end of
the line to indicate that the record continues on the next line.

Subsequently, you having something like this:

Record1, FieldData1, FieldData2, FieldData3
Record2, FieldData4, FieldData5, FieldData6
Record3, FieldData7-
FieldData8, FieldData9
Record 4, FieldData10, FieldData11, FieldData12
....

and so on.

What I am wanting to do is use a sed script to remove any occurence of "-\n"
and replace it with no characters at all.

By this means I hope to get those records that are split over multiple
lines, to all be on one relatively large single line that I can then grep
through, while still getting the entire record returned from grep.

To do this, I have written a sed command like this:


	sed s/-\n//g myfilename.txt > my_new_filename.txt

However, this does not seem to do what I want it to. 

Can anyone see an obvious error in this command?

thanks heaps all

David Buddrige.


This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



More information about the plug mailing list