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

Russell Steicke russells at plug.linux.org.au
Thu Jul 11 12:17:38 WST 2002


On Thu, Jul 11, 2002 at 01:48:31PM +1000, Buddrige, David wrote:
...
> 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.
...
> 	sed s/-\n//g myfilename.txt > my_new_filename.txt
> 
> However, this does not seem to do what I want it to. 

sed is probably not suitable for this task, but awk can do it:

  awk '/-$/ {gsub(/-$/," "); getline lyne; print $0 lyne; next;} {print;}' \
    < infile > outfile



More information about the plug mailing list