|
|
Subject:
UNIX text processing
Category: Computers > Programming Asked by: philnj-ga List Price: $2.00 |
Posted:
09 Aug 2006 10:29 PDT
Expires: 08 Sep 2006 10:29 PDT Question ID: 754319 |
I have an ASCII file on a Solaris UNIX system. Some lines in the file end with a continuation character \ then a newline character then the line continues on the next line. Lines are never broken into more than two lines. I need a vi command or a sed command that will remove the continuation character and concatenate the two lines into one full line (with a newline at the end). |
|
Subject:
Re: UNIX text processing
Answered By: bookface-ga on 09 Aug 2006 10:50 PDT |
# if a line ends with a backslash, append the next line to it sed -e :a -e '/\\$/N; s/\\\n//; ta' This file is invaluable for anybody ever needing to do any text processing on a system containing sed: http://www.student.northpark.edu/pemente/sed/sed1line.txt If no exact match for what you want to do is there, you can generally find a similar solution that'll put you well in the right direction. | |
| |
| |
|
|
Subject:
Re: UNIX text processing
From: frankcorrao-ga on 15 Aug 2006 14:42 PDT |
Are you sure there was not already a space before the escaped newline in the input data? This sed command will not replace the newline with a space. The 's/\\\n//' portion of the command means replace backslash and newline with nothing. If you copied this down instead of cut and paste it make sure there is no space between the last two slashes of this part of the command. If this was a space before the escaped newline in the original input, you can remove that one as well by changing the command very slightly to: sed -e :a -e '/\\$/N; s/ \\\n//; ta' Note the space after "s/". |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |