Need to include two more columns in the file using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to include two more columns in the file using awk
# 1  
Old 02-23-2012
Need to include two more columns in the file using awk

Hi,

I have a input file with many records as below:
1J4RR4GG0BC508200 68646 1 N M

i want my output file to be like with columns included dgismdh and timestamp :

Example:

1J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591

How to do it.can we do using awk?
Pls help.
# 2  
Old 02-23-2012
Code:
nawk '{$NF=$NF" dgismdh 2012-02-21 07:22:25.98591";}1' input.txt > output.txt

# 3  
Old 02-23-2012
Through Sed..
Code:
sed "s/$/ dgismdh $(date)/" inputfile

# 4  
Old 02-23-2012
Thanks for replying.

But I am getting output using awk as :
dgismdh 2012-02-21 07:22:25.98591

i want it to be appended after the columns already present
EX:

1J41J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591

Please reply .
# 5  
Old 02-23-2012
awk

Hi,

Try this one,

Code:
awk '{print $0"dgismdh 2012-02-21 07:22:25.98591";}' inputFile

Cheers,
RangaSmilie
# 6  
Old 02-23-2012
Quote:
Originally Posted by sonam273
Thanks for replying.

But I am getting output using awk as :
dgismdh 2012-02-21 07:22:25.98591

i want it to be appended after the columns already present
EX:

1J41J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591

Please reply .
Can you post the command you tried ?
# 7  
Old 02-23-2012
Hi itkamaraj,

I have used the below command:
nawk '{$NF=$NF" dgismdh 2012-02-21 07:22:25.98591";}1' input.txt > output.txt

Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Include information in certain columns using grep and awk

HI all, I have data in a file that looks like this: 1 HOW _ NNP NNP _ 3 nn _ _ 2 DRUGS _ NNP NNP _ 3 nn _ _ 3 ACT _ NNP NNP _ 0 null _ _ 4 : _ ... (3 Replies)
Discussion started by: owwow14
3 Replies

2. Shell Programming and Scripting

Mention file include on command line: awk

Hi All: I need your help please. I have a include file *.awk , and I would want to know if it's there a option's awk where I can use this file include, for example: awk -f decodifica_bitmap.awk cadena_hex.txt -e /home/snh/Awk/include/funciones.awk > sal.out it give error: awk:... (1 Reply)
Discussion started by: solaris21
1 Replies

3. Shell Programming and Scripting

awk filter by columns of file csv

Hi, I would like extract some lines from file csv using awk , below the example: I have the file test.csv with in content below. FLUSSO;COD;DATA_LAV;ESITO ULL;78;17/09/2013;OL ULL;45;05/09/2013;Apertura NP;45;13/09/2013;Riallineamento ULLNP;78;17/09/2013;OL NPG;14;12/09/2013;AperturaTK... (6 Replies)
Discussion started by: giankan
6 Replies

4. Shell Programming and Scripting

How to parse fixed-width columns which may include empty fields?

I am trying to selectively display several columns from a db2 query, which gives me a fixed-width output (partial output listed here): --------- -------------------------- ------------ ------ 000 0000000000198012 702 29 000 0000000000198013 ... (9 Replies)
Discussion started by: ahsh79
9 Replies

5. Shell Programming and Scripting

Awk to add columns from a file into an existing file

Hi! I would need some help to add the last two columns of one file into another file using awk (or something similar). For example, I have: file 1: file 2: car book day root lag bar look pay boot tag tar took may moot sag I want to have:... (5 Replies)
Discussion started by: coconaza
5 Replies

6. Shell Programming and Scripting

using awk to print some columns of a file

Hi, i have a file with content 00:01:20.613 'integer32' 459254 00:01:34.158 459556 00:01:36.626 'integer32' 459255 and i want to print only output as below 00:01:20.613 459254 00:01:34.158 459556 00:01:36.626 459255 i dont want the word 'integer32' which is the second column. i... (2 Replies)
Discussion started by: dealerso
2 Replies

7. Shell Programming and Scripting

awk some columns from file

I have a file that has a list in this format: abcdefg|mia21acs.acs.oaklahoma.net|10.83.19.21|||PROV|ADTHNION21E|USA|DLAR|CISCO||OS|1.0.7.10 abcdefg|cle22acs.acs.oaklahoma.net|10.83.19.22|||PROV|ADTHNION22E|USA|DLAR|CISCO||OS|1.0.7.10 I need to pull the red highlighed fileds so the output looks... (2 Replies)
Discussion started by: numele
2 Replies

8. Shell Programming and Scripting

how to include the missing column in the original file using awk

Hi Experts, The content of the raw file: date,nomsgsent,nomsgnotdeliver,nomsgdelay 201003251000,1000,1,2 201003251000,900,0,0 201003251000,1450,0,0 201003251000,1230,0,0 However, sometimes, the column will missing in the raw files: e.g. date,nomsgsent,nomsgdelay... (8 Replies)
Discussion started by: natalie23
8 Replies

9. Shell Programming and Scripting

Using awk to substitute columns from one file into another

Hi, I am new to this forum and my script skills are very weak. I have this file (file 1) that contains 3 columns (tab delimited): kyle start stop john start stop joe start stop And I want to replace name (column 1) from another file. This other file has two columns, one is the... (4 Replies)
Discussion started by: kylle345
4 Replies

10. UNIX for Dummies Questions & Answers

How to include 'date' in my awk?

Hi, I have problem in including date in side awk, my code as follows: performace=performace.txt reporttime=`date` cat $performace | grep "testString" | awk '{ if ($3 > 20 ){print $reporttime $1 $2 $3}}' >> $rpt $reporttime is not reflecting properly in my report file($rpt)? how to... (3 Replies)
Discussion started by: redlotus72
3 Replies
Login or Register to Ask a Question