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


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to add field to diffrent file using shellscript? or awk
# 1  
Old 02-13-2019
How to add field to diffrent file using shellscript? or awk

hi,
would you help me?
i have file total.csv

Code:
"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:
Code:
 
"a,"e23","f" 3
 "b,"34d","g"
 "c","45f","f"
 "d","45s","f"

i want the output like this:
Code:
 
"a,"e23","f","3"
 "b,"34d","g","3"
 "c","45f","f","3"
 "d","45s","f","3"

Moderator's Comments:
Mod Comment MOD's comment: Please wrap your samples of input and expected output in [CODE]...........[/CODE] tags.

Last edited by RavinderSingh13; 02-13-2019 at 04:52 AM..
# 2  
Old 02-13-2019
Moderator's Comments:
Mod Comment This thread duplicates your previous thread (How to add field to diffrent file?). Please continue any discussion on this topic there.

This thread is closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using awk to add length of matching characters between field in file

The awk below produces the current output, which will add +1 to $3. However, I am trying to add the length of the matching characters between $5 and $6 to $3. I have tried using sub as a variable to store the length but am not able to do so correctly. I added comments to each line and the... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

awk to add text to matching pattern in field

In the awk I am trying to add :p.=? to the end of each $9 that matches the pattern NM_. The below executes andis close but I can not seem to figure out why the :p.=? repeats in the split as in the green in the current output. I have added comments as well. Thank you :). file ... (4 Replies)
Discussion started by: cmccabe
4 Replies

3. Shell Programming and Scripting

awk to add plus or minus to fields and split another field

In the tab-delimited input below I am trying to use awk to -10 from $2 and +10 to $3. Something like awk -F'\t' -v OFS='\t' -v s=10 '{split($4,a,":"); print $1,$2-s,$3+s,a,$5,$6} | awk {split(a,b,"-"); print $1,$2-s,$3+s,b-s,b+s,$5,$6}' input should do that. I also need to -10 from $4... (2 Replies)
Discussion started by: cmccabe
2 Replies

4. Shell Programming and Scripting

awk to add symbol to specific field

Trying to use awk to add a . to $4. The input and output is tab-delimeted, but the awk seems to add a . in front of $5 and is space-delimeted. It seems close, but I am not able to produce the desired output. Thank you :). file chr1 948895 949015 chr1:948895-949015 ISG15 chr1 ... (1 Reply)
Discussion started by: cmccabe
1 Replies

5. Shell Programming and Scripting

Add field header and default value in awk

I am trying to add a field header Inheritence in between $9 and $10 and default the value of each line to .. The below awk is close I think. Thanks :). input R_Index Chr Start End Ref Alt Func.IDP.refGene Gene.IDP.refGene ... (4 Replies)
Discussion started by: cmccabe
4 Replies

6. Shell Programming and Scripting

awk to skip header row and add string to field

The awk below does put in VUS in the 9th field but I can not seem to skip the header then add the VUS. I tried to incorporate NR >=2 and NR > 1 with no luck. Thank you :). input Chr Start End Ref Alt Func.refGene PopFreqMax CLINSIG Classification chr1 43395635 ... (5 Replies)
Discussion started by: cmccabe
5 Replies

7. Shell Programming and Scripting

awk to remove field and match strings to add text

In file1 field $18 is removed.... column header is "Otherinfo", then each line in file1 is used to search file2 for a match. When a match is found the last four strings in file2 are copied to file1. Maybe: cut -f1-17 file1 and then match each line to file2 file1 Chr Start End ... (6 Replies)
Discussion started by: cmccabe
6 Replies

8. Shell Programming and Scripting

AWK : Add Fields of lines with matching field

Dear All, I would like to add values of a field, if the lines match in a certain field. Then I would like to divide the sum though the number of lines that have a matched field. This is the Input: Input: Test1 5 Test1 10 Test2 2 Test2 5 Test2 13 Test3 4 Output: Test1 7.5 Test1 7.5... (6 Replies)
Discussion started by: DerSeb
6 Replies

9. Shell Programming and Scripting

awk field equal something, then add something to the field

Hi Everyone, a.txt a b c 1 e e e e e a b c 2 e e e e e the output is a b c 1 e e e e e a 00b c 2 e e e e e when 4th field = '2', then add '00' in the front of 2nd field value. Thanks (9 Replies)
Discussion started by: jimmy_y
9 Replies

10. 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
Login or Register to Ask a Question