![]() |
|
|
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 |
| Break lines up into single lines after each space in every line | lewk | Shell Programming and Scripting | 7 | 10-14-2009 10:33 AM |
| join lines on line break in files | mad_man12 | Shell Programming and Scripting | 6 | 07-31-2009 11:29 AM |
| Break one line to many lines using awk | pinnacle | Shell Programming and Scripting | 16 | 06-01-2009 03:05 AM |
| retrieved multiple lines on multiple places in a file | dala | Shell Programming and Scripting | 8 | 03-14-2008 03:28 PM |
| How to count lines - ignoring blank lines and commented lines | kthatch | UNIX for Dummies Questions & Answers | 6 | 05-25-2007 02:21 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Awk to Break lines to multiple lines.
Input File: Quote:
Code:
nawk -F "|" '{
for(i=1;i<=NF;i++) {
if (i == 2)
{gsub(",","#",$i);z=split($i,a,"[#]")}
else if (i == 3)
{gsub(",","#",$i);z=split($i,b,"[#]")}
}
if(z > 0) for(i=1;i<=z;i++)
print $1,a[i],"Test";
if(w > 0) for(j=1;j<=w;j++)
print $1,b[j],"Testing";
z=0;w=0
}' OFS="|" awktest.txt
Required Output: Quote:
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|