![]() |
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 |
| Formatting Output | dhanamurthy | Shell Programming and Scripting | 6 | 05-02-2008 11:43 AM |
| Formatting bdf output | Cameron | Shell Programming and Scripting | 5 | 04-09-2008 09:05 AM |
| formatting output | balaji_prk | Shell Programming and Scripting | 4 | 09-15-2007 09:23 AM |
| Formatting output | illur81 | Shell Programming and Scripting | 3 | 10-13-2005 09:24 AM |
| Formatting the output | Cameron | Shell Programming and Scripting | 7 | 02-15-2002 10:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Formatting Output file
Hi, I have a file....
File1: Num Name ID Place ADDR City Country 1024|Name1|ID1|Street1|ADDR1|Boston|UK 1025|Name2|ID3|Street2|ADDR2|London|USA The above file is varaiable length file. I have to insert 2 values in every record of the above file. Output: 1024|Name1|XX|ID1|Street1|ADDR1|YY|Boston|UK 1025|Name2|XX|ID3|Street2|ADDR2|YY|London|USA As given above I need XX and YY values at third and Seventh column of every record in the file. Please let me know how to do it. Thanks in advance. |
|
||||
|
Code:
# cat aaa
Num Name ID Place ADDR City Country
1024|Name1|ID1|Street1|ADDR1|Boston|UK
1025|Name2|ID3|Street2|ADDR2|London|USA
# awk 'FS=OFS="|" {if (NR == 1) print $0; else print $1,$2,"XX",$3,$4,$5,"YY",$6,$7}' aaa
Num Name ID Place ADDR City Country
1024|Name1|XX|ID1|Street1|ADDR1|YY|Boston|UK
1025|Name2|XX|ID3|Street2|ADDR2|YY|London|USA
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|