Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Need a help in AWK

$
0
0
HI guys i have a file
Code:

cat file1
00510010 0000000471 482.90 5855.49

00510015 0000000471 2280.81 3093.79

00510020 0000000471 23640.82 22857.28

00510021 0000000471 3455.12 0

Now, I need the 4th column copied over 10 more times, so I would have 14 columns in total.

I tried this
Code:

awk '{for (i=1; i<=10; i++) {printf "%s %s",$NF,$i}} 1' file1 OFS=','
Am getting the o/p reversely
Code:

5855.49 5855.49 5855.49 5855.49 5855.49 5855.49 00510010 0000000471 482.90 5855.49
     
3093.79 3093.79 3093.79 3093.79 3093.79 3093.79 00510015 0000000471 2280.81 3093.79
     
22857.28 22857.28 22857.28 22857.28 22857.28 22857.28 00510020 0000000471 23640.82 22857.28
     
0 0 0 0 0 0 00510021 0000000471 3455.12 0

Columns are added at the beginning instead of the end.. I want add from the 5th column..
Help me Please..

Viewing all articles
Browse latest Browse all 16232

Trending Articles