![]() |
|
|
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 |
| combining lines in files | sme | Shell Programming and Scripting | 14 | 10-17-2008 04:47 AM |
| help combining lines in awk | blueheed | Shell Programming and Scripting | 2 | 03-23-2006 06:26 PM |
| need help appending lines/combining lines within a file... | mr_manny | Shell Programming and Scripting | 2 | 01-06-2006 06:45 PM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 03:41 PM |
| Combining multiple lines | DUST | Shell Programming and Scripting | 4 | 07-15-2005 11:57 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
combining lines between 2 pattern using awk
Hi
I am fairly new to shell scripting i have some file with outout 1011 abc fyi 6.1.4.5 abr tio 70986 dfb hji 4.1.7 ....some text 111114 i have to format this text to 1011 abc fyi 6.1.4.5 abr tio 70986 dfb hji 4.1.7 ....some text 111114 basically combine the lines between the patterns that have whole numbers is this possible in a simple awk script? Thanks much |
|
||||
|
I didn't, but now I do.
Code:
awk '$1 ~ /^[1-9][0-9]*$/{ if (NR > 1) printf "\n"; printf "%s", $0; next; }
{ printf " %s", $0; }
END { printf "\n" }' filename
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|