Adding an additional blank field to a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding an additional blank field to a file
# 1  
Old 04-30-2012
Adding an additional blank field to a file

Hi,
I have the following file, I'd like to add an additional blank field to this file
This is a tab delimited file, I have tried the same thing on excel, but looking for a unix solution.

Here is my input:
Code:
Country  Postal  Admin4  StreetBaseName  StreetType
HUN      2243    Kóka    Dózsa György   út
HUN      5475    Csépa   4511

I'm expecting this output:
Code:
Country  Postal  Admin4  HNO  StreetBaseName  StreetType
HUN      2243    Kóka        Dózsa György   út
HUN      5475    Csépa       4511

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data
# 2  
Old 04-30-2012
Is this file tab-separated?
# 3  
Old 04-30-2012
yes it is a tab seperated file
# 4  
Old 04-30-2012
You can "cheat" by putting two fields in one.

Code:
awk -v FS="\t" -v OFS="\t" 'NR==1 { $3=$3 "\tHNO"; print; next}; { $3=$3 "\t" ; print }' filename > outputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Adding Additional Capacity with megacli

I'm trying to add 6 more hard drives to my RAID array, none of the drives are foreign, they won't be replacing any drives either. I just need to add them to the RAID array. I can't seem to get them added, what am I missing? ---------- Post updated 08-03-12 at 12:28 PM ---------- Previous... (0 Replies)
Discussion started by: eccentricson
0 Replies

2. Shell Programming and Scripting

bash : Adding numeric order to blank field

Hi All, I have a file menu_opts is as follows # cat menu_opts Please select the options qqqq_usb STD RETAIL Progs (Prime time cue advertisements) qqqq_onc STD Dealer Progs (Prime time cue advertisements) qqqq_zt_usb STD RETAIL Progs (Long Format cue... (2 Replies)
Discussion started by: maverick_here
2 Replies

3. Shell Programming and Scripting

Text file to CSV with field data separated by blank lines

Hello, I have some data in a text file where fields are separated by blank lines. There are only 6 fields however some fields have several lines of data as I will explain. Also data in a particular field is not consistently the same size but does end on a blank line. The first field start with... (6 Replies)
Discussion started by: vestport
6 Replies

4. Shell Programming and Scripting

replace blank field in file 2 with content of file 1

Something like vlookup in excel, column 2 in file 2 is blank and should be replaced by column 2 in file 1 based on comparing column 1 in both files. file1 Code: 1234~abc~b~c~d~e~f~g~h~09/10/09 5678~def~b~c~d~e~f~g~h~12/06/10 8910~hij~b~c~d~e~f~g~h~03/28/13... (1 Reply)
Discussion started by: sigh2010
1 Replies

5. AIX

Any Additional Steps After Adding New RAM To Sever?

Hi All, We have a server at a client site running AIX 5.3, which we just up the RAM to 32GB, from initially 16GB (if I'm not mistaken). This server is our Application server running J2EE applications on top of Oracle Internet Application Server. Recently we encountered one of the batch jobs... (12 Replies)
Discussion started by: a_sim
12 Replies

6. Shell Programming and Scripting

Adding additional characters while preserving original text

Hi Forum. I'm struggling on this relatively easy request to add additional 4 0's to an existing text in a file (whenever I see the pattern -# where # represents any number) using sed command while preserving the rest of the text in the files. Original Text: $DBConnection_EDW=SAS2EDW... (5 Replies)
Discussion started by: pchang
5 Replies

7. Shell Programming and Scripting

Adding additional column at the end

I have a file like below. The separator between reconds is ">" Each record consists of 2 numbers separated by a space. I want to write an awk script that copies the second number and puts it in the third column. :rolleyes: > 10 0 13 5.92346 16 10.3106 19 13.9672 22 16.9838 25... (5 Replies)
Discussion started by: kristinu
5 Replies

8. UNIX for Advanced & Expert Users

adding additional drive to sco the is xenix

I am taking an old xenix drive and installing it in a recent SCO Build Server. I have gone through the process of running mkdev hd twice since the drive is a SCSI then proceed to run mkdev fs and when I attempt to add one of the shown partitions I get the following: fsck: cannot determine... (1 Reply)
Discussion started by: justenglabs
1 Replies

9. UNIX for Dummies Questions & Answers

Adding an additional harddrive in solaris 9

Hello, I have a system which a new harddrive was installed for additional space. I now need to mount the drive and transfer data from /home to the new drive with a mount point named /home. How do I go about doing this? Thanks in advance. (5 Replies)
Discussion started by: GLJ@USC
5 Replies
Login or Register to Ask a Question