![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ksh scripting help | praveenbvarrier | Shell Programming and Scripting | 1 | 04-15-2008 10:19 AM |
| Scripting Help! | liezer | Shell Programming and Scripting | 7 | 09-15-2006 03:52 AM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 08:12 AM |
| scripting guru's pls help me with scripting on AIX | thatiprashant | Shell Programming and Scripting | 1 | 01-20-2006 07:58 PM |
| HELP! Need HELP scripting! | adawg1283 | Shell Programming and Scripting | 7 | 09-29-2004 03:48 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
AWK scripting
I have a text file in which the text has been divided into paragraphs (two line breaks or tab marks a new paragraph) and I want to make a script which output would delete line breaks within the paragraph and the different paragraphs would be separated by two line breaks.
So, if my input file is: Code:
The first line. Second line. First line of the second paragraph. Second line of the second paragraph. Code:
The first line. Second line. First line of the second paragraph. Second line of the second paragraph. Thanks! |
|
||||
|
The output of Tytalus' code is pretty much what needed, but yes, I want it to work with paragraphs longer than 2 lines as well. But I really didn't understand the code itself very well to change it properly. Could someone explain it a bit or give ideas of how to change it?
|
|
||||
|
vgersh99, with your solution I get this:
Code:
$ nawk 'BEGIN {FS=RS=""; ORS="\n\n\n"} $1=$1' file
T h e f i r s t l i n e .
S e c o n d l i n e .
F i r s t l i n e o f t h e s e c o n d p a r a g r a p h .
S e c o n d l i n e o f t h e s e c o n d p a r a g r a p h .
Code:
$ awk 'BEGIN {RS=ORS="\n\n"} $1=$1' file
The first line. Second line.
First line of the second paragraph. Second line of the second paragraph.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| sed delete line |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|