![]() |
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 |
| perl: storing regex in array variables trouble | xist | Shell Programming and Scripting | 3 | 08-29-2008 09:07 AM |
| storing variables in array.Please help | nua7 | Shell Programming and Scripting | 7 | 07-17-2008 10:47 AM |
| Storing pointer array in C | arunkumar_mca | UNIX for Dummies Questions & Answers | 1 | 08-23-2007 09:49 AM |
| Count No of Records in File without counting Header and Trailer Records | guiguy | Shell Programming and Scripting | 2 | 06-07-2007 01:15 PM |
| Getting database records in an array | rawat_me01 | Shell Programming and Scripting | 2 | 05-07-2007 01:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
storing records in awk array
hi i have a file as follows:
Code:
1 2 3 4 5 6 Code:
awk '{for(i=1;i<=NR;i++) {a[i]=$1}} END {for(i=1;i<=NR;i++) {printf("%1.11f",a[i])}}' 1.csv > test
appreciate any help. |
|
||||
|
ok thanks that worked..
here is what i want to do next. i have this file called test which has values as follows: Code:
1 2 3 4 5 6 7 (there are more columns but following is just a snapshot of the file) Code:
col1 col2 1 1.4 2 1.6 3 1.7 4 1.8 5 1.9 6 2.0 Code:
col1 col2 1-1 1.4-2 2-1 1.6-2 3-1 1.7-2 4-1 1.8-2 5-1 1.9-2 6-1 2.0-2 Code:
awk 'NR==FNR{for(i=1;i<=NF;i++) {a[NR]=$i;next} {b[NR]=$i;next} END {for(i=1;i<=NF;i++) {printf("%1.11f, %1.11f\n",a[i],b[i])}}' test data > try
thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|