awk command to copy field to bottom records


View Poll Results: awk command to pivot records
Like 0 0%
Dont like 0 0%
Voters: 0. This poll is closed

 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers awk command to copy field to bottom records
# 1  
Old 05-14-2014
awk command to copy field to bottom records

Hi All,

I have a below input, I want to copy the Job_name and Created_by field information to other bottom records as shown in below Output

Code:
Job_name Created_by Modified_on Modified_by
CGI_ACLMIB n38504 2014-05-07 20:40:48 n38504
2014-05-07 20:40:57 n38504
2014-05-08 20:40:57 n48504


Output
--------
Code:
Job_name Created_by Modified_on Modified_by
CGI_ACLMIB n38504 2014-05-07 20:40:48 n38504
CGI_ACLMIB n38504 2014-05-07 20:40:57 n38504
CGI_ACLMIB n38504 2014-05-08 20:40:57 n48504


Is there any way we can achive using awk command


Thanks,
Somaraju

Last edited by Franklin52; 05-14-2014 at 04:57 AM.. Reason: Please use CODE tags, not ICODE tags for code blocks. Thanks.
# 2  
Old 05-14-2014
Try:
Code:
awk 'NR==2{job=$1;created=$2} NF==3 {print job FS created FS $0} NF>3' inputfile

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk - If field value of consecutive records are the identical print portion of lines

I have some data that looks like this: PXD= ZW< 1,6 QR> QRJ== 1,2(5) QR> QRJ== 4,1(2) QR> QRJ== 4,2 QRB= QRB 4,2 QWM QWM 6,2 R<C ZW< 11,2 R<H= R<J= 6,1 R>H XZJ= 1,2(2) R>H XZJ= 2,6(2) R>H XZJ= 4,1(2) R>H XZJ= 6,2 RDP RDP 1,2 What I would like to do is if fields $1 and $2 are... (5 Replies)
Discussion started by: jvoot
5 Replies

2. Shell Programming and Scripting

awk command to return only field with a number in it

What is an awk command to print only fields with a number in it?? Input file....... S,S,S,S,S,S,S,S,S 001S,S,S,S,S,S,S,S,S 00219S,23S,24S,43S,47S,S,S,S,S 00319S,10S,23S,41S,43S,47S,S,S,S 00423S,41S,43S,46S,47S,S,S,S,S 00510S,23S,24S,43S,46S,S,S,S,S 00610S,23S,43S,46S,47S,S,S,S,S... (2 Replies)
Discussion started by: garethsays
2 Replies

3. Shell Programming and Scripting

Find and copy files with field lower than a value, awk?

Hi all! I have 10.000 files having generally this format: text text text text num text num text num text text text GAP number text text text num text num text num RMS num text num text num text num ... what I want is to copy the files if the GAP number is lower than a value e.g. <100... (5 Replies)
Discussion started by: phaethon
5 Replies

4. Shell Programming and Scripting

Pass awk field to a command line executed within awk

Hi, I am trying to pass awk field to a command line executed within awk (need to convert a timestamp into formatted date). All my attempts failed this far. Here's an example. It works fine with timestamp hard-codded into the command echo "1381653229 something" |awk 'BEGIN{cmd="date -d... (4 Replies)
Discussion started by: tuxer
4 Replies

5. Shell Programming and Scripting

Need a very specific awk command for parsing records

I have data in a file where the first line of the file identifies the fields. I need to be able to parse out any single record, field-by-field, with the fields identified. So if my file looks like this: NAME, ADDRESS, PHONE Jim Smith, 123 Main Street, 999-888-7777 Bob Jones, 555 Park Avenue,... (6 Replies)
Discussion started by: Finja
6 Replies

6. Shell Programming and Scripting

Splitting record into multiple records by appending values from an input field (AWK)

Hello, For the input file, I am trying to split those records which have multiple values seperated by '|' in the last input field, into multiple records and each record corresponds to the common input fields + one of the value from the last field. I was trying with an example on this forum... (4 Replies)
Discussion started by: imtiaz99
4 Replies

7. UNIX for Advanced & Expert Users

Awk command to print the field

894344202808090;11122;040320 075858 166;101;0;0;10u;0;NA;65;221890;2;101973;185059;568674;Y; PRE;0;0;NA;NA;0;NA;0;NA;textmsg;textmsg_snd1;telusmob;TEXTMSG1;0.15000000;126037;2010/03/04 12:58:57gmt;0;70532192; plz tell me any awk command which on the basis of the yellow field which is... (1 Reply)
Discussion started by: madfox
1 Replies

8. Shell Programming and Scripting

awk command to separate a field

I have a log file that I am trying to convert. File contents something like this: aaaaa bbbbbb cccc dddddd\123 eeeee ffffffff I am trying to output the fields in a different order and separate field 4 so that the "123" and "dddddd" can be output separately. for example bbbbbb aaaaa 123... (5 Replies)
Discussion started by: jake1988
5 Replies

9. Shell Programming and Scripting

awk field separator or print command

Hello Experts, I am back, with another doubt. I am not sure what it relates to this time - awk or the print command actually. I'll explain the scenario: I have a huge file, and it has some traces(logs). In between those logs, there are statements with some SQL queries. All I want to do is... (4 Replies)
Discussion started by: hkansal
4 Replies

10. Shell Programming and Scripting

awk command for finding field in a file

hi guys i have this file with column number 7 as below: 0 1416 49 37 5 3 2 0 0 0 21 0 26 ... (5 Replies)
Discussion started by: npatwardhan
5 Replies
Login or Register to Ask a Question