Fetch the field from file and add to new file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fetch the field from file and add to new file.
# 1  
Old 04-16-2007
Fetch the field from file and add to new file.

Admins

Pls. assist me to update a new field having 40 rows to a file.

Test1.output

LV Space %free Space_used_04_15
dev 500 7 67%
dev1 800 7 75%
dev2 800 7 75%
dev3 900 7 75%
dev4 900 7 75%

Test2.output
Space_used_04_16
78%
88%
89%
95%
90%


I want to join the field from Test2.output to Test1.output and make the file output as shown below:

Expected Result

LV Space %free Space_used_04_15 Space_used_04_16

dev 500 7 67% 68%
dev1 800 7 75% 68%
dev2 800 7 75% 68%
dev3 900 7 75% 68%
dev4 900 7 75% 68%

Options tried as
awk '{print $NF}' Test1.output to fetch the last field. But trying to join the result of Test2.output to the file Test1.output.

Help me...

Cheers
Ar.B
# 2  
Old 04-16-2007
Code:
$ paste Test1.output Test2.output
LV Space %free Space_used_04_15         Space_used_04_16
dev 500 7 67%   78%
dev1 800 7 75%  88%
dev2 800 7 75%  89%
dev3 900 7 75%  95%
dev4 900 7 75%  90%

# 3  
Old 04-18-2007
thanks anbu..i didn't hear paste command so far..nice to know from u.

Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to add field to diffrent file using shellscript? or awk

hi, would you help me? i have file total.csv "a","e23","f" "b,"34d","g" "c","45f","f" "d","45s","f" count.csv 3 i do this : paste -d',",' total.csv count.csv but the result like this: "a,"e23","f" 3 "b,"34d","g" (1 Reply)
Discussion started by: kivale
1 Replies

2. Shell Programming and Scripting

Add tab after digit in specific field in file

I am trying to add a tab after the last digit in $3 in the input. The grep below is all I can think off. Thank you :) sed -n 's/:/&/p' input input chr1 955542 955763AGRN-6|gc=75 chr1 957570 957852AGRN-7|gc=61.2 chr1 976034 976270AGRN-9|gc=74.5 desired output chr1... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. Shell Programming and Scripting

Bash file 1 and file then add field

Hi All, Seeking for your assistance regarding on how to bash file 1 and file 2 then add the field if the bash is true. Ex. nik1.csv - input file 1 1,0054,0001,4,5,6,7,May 1,USA 11,0053,0002,14,15,16,17,May 2,PHL 40,0052,0003,43,44,45,46,May 5,GER nik2.csv - input file 2... (11 Replies)
Discussion started by: nikki1200
11 Replies

4. UNIX for Dummies Questions & Answers

Find and add a field for an input file

Hello Sir/Madam, I'm new to UNIX and wondering if I can process a find & add using AWK command in UNIX? requirements: I have to find *.JPG field for each line in the input file and add it as a separate field for each line.. for ex: 0000684631,E,3088017,7... (10 Replies)
Discussion started by: V1l1h1
10 Replies

5. Shell Programming and Scripting

make the name of file and fetch few things from log file

Hello All, I am working on a script where I need to fetch the value from a log file and log file creates with different name but few thing are common DEV_INFOMGT161_MULTI_PTC_BLD01.Stage_All_to_stp2perf1.042312114644.log STP_12_02_01_00_RC01.Stage_stp-domain_to_stp2perf2.042312041739.log ... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

6. Shell Programming and Scripting

awk or sed to add field in a text file

Hi there, I have a csv file with some columns comma sepated like this : 4502-17,PETER,ITA2,LEGUE,92,ME - HALF,23/05/10 15:00 4502-18,CARL,ITA2,LEGUE,96,ME - HALF,20/01/09 14:00 4502-19,OTTO,ITA2,LEGUE,97,ME - MARY,23/05/10 15:00 As you can see the column n. 7 is a timestamp column, I need... (23 Replies)
Discussion started by: capnino
23 Replies

7. Shell Programming and Scripting

How to add text to a field within a csv file

I have a csv file which has three columns mem no. name surname 1234 John Smith 12345 John Doe I want to change the mem no. to add TF to the mem no. field i.e. mem no. name surname 1234TF John Smith 12345TF John Doe How do you do this for all records in the file? (3 Replies)
Discussion started by: Pablo_beezo
3 Replies

8. Shell Programming and Scripting

Add a field seperator in a file.

"355"|""|"NJ"|"A0A 1W0"|"V"|""|""|""|"N" I've the above sample data seperated with pipe delimeter and in the file I want to replace a space with "|" to the 4th field so the result would be like below. So it would change from 9 fields to 10 fields. "355"|""|"NJ"|"A0A"|"1W0"|"V"|""|""|""|"N" ... (3 Replies)
Discussion started by: rudoraj
3 Replies

9. Shell Programming and Scripting

Fetch lines from a file matching column2 of another file

Hi guys, Please help me out in this problem. I have two files FILE1 abc-23 : 4529675 cde-42 : 9824532 dge-91 : 1245367 gre-45 : 9824532 fgr-76 : 4529675 FILE2 4529675 : Gal Glu house-2-be 9824532 : cat mouse 1245367 : sirf surf-2-beta where FILE2 is a static file with fixed... (5 Replies)
Discussion started by: smriti_shridhar
5 Replies

10. Shell Programming and Scripting

add lines automatically based on a field on another file

hello I have a number of lines that need to be added at the end of a file each time I add a field in another file (let's name it file2) file2 has this format: filed1:field2:path1:path2:path3:path... Whenever I add a path field, I should add to file1 these lines: <Location path1>... (0 Replies)
Discussion started by: melanie_pfefer
0 Replies
Login or Register to Ask a Question