![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tables and borders | amatuer_lee_3 | Shell Programming and Scripting | 8 | 05-15-2008 01:57 PM |
| Converting tables of row data into columns of tables | justthisguy | Shell Programming and Scripting | 7 | 07-16-2007 01:42 PM |
| Routing tables | kingdbag | UNIX for Dummies Questions & Answers | 9 | 10-06-2006 05:01 PM |
| viewing tables | itldp | UNIX for Dummies Questions & Answers | 2 | 12-17-2003 05:19 AM |
| PHP: list into tables | perleo | Shell Programming and Scripting | 2 | 10-01-2003 06:50 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
awk - list to tables
Hello there,
I have large tab-delimitated lists (see input file) and I need to convert it into tab-delimitated tables (see output file). I would like to do it with an awk script. Any ideas? Input file: header1 <tab> a <tab> a <tab> a <tab> a . . . header2 <tab> b <tab> b <tab> b <tab> b . . . header3 <tab> c <tab> c <tab> c <tab> c . . . header4 <tab> d <tab> d <tab> d <tab> d . . . . . . Output file: header1 <tab> header2 <tab> header3 <tab> header4 . . . a <tab> b <tab> c <tab> d . . . a <tab> b <tab> c <tab> d . . . a <tab> b <tab> c <tab> d . . . a <tab> b <tab> c <tab> d . . . . . . |
| Forum Sponsor | ||
|
|
|
|||
|
Dear shamrock,
Thanks for the help - I have problems to execute the script. I'm not sure it the problem is the $1 at the end? ./r2c.sh file.input ########################### #!/bin/bash awk ' { for(f=1; f<=NF; f++) r2c[f","NR] = $f } END { for(f=1; f<=NF; f++) { for(row=1; row<=NR; row++) printf("%s\t", r2c[f","row]) print "" } }' $1 ######################### |
|
|||
|
I tried your version of the script with the following ending:
...}' file executing the script with: r2c.sh --- and I tried the following ending: ...}' $1 executing the script with: r2c.sh file But nothing happens. |
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|