I'm using the following code to add two new columns (15 and 16) to a tab delim txt file based on calculations from other existing columns.
Problem: new column data is shown in terminal but file is not updated with columns. when sent to another file (code ... > Sample.....2.txt
) the columns are present but the delimiter is changed from tab to space.
Need: to add column 15 and 16 based on calculations on existing columns in a tab delimited file in one line of code.
file : Sample1_RVDB_sort_unique.txt
code:
awk '{$15 = ($4/$13)*100; $16 = ($4/$14)*100; print}' Sample1_RVDB_sort_unique.txt
Data
utg000001l acc|GENBANK|MH883318.1|White 80.263 608 99 16 282 877 184245 184843 4.44e-120 438 2022 270609
-i
option or@include
directive? (2) Your file is what it is. But for the purpose of the question, you could have showed us a four-column file where you want to add$5
and$6
. That way you could have avoided having data that’s wider than the screen. (3) I don’t know whatcode ... > Sample.....2.txt
means. Better to show the actual command. – G-Man Says 'Reinstate Monica' Aug 23 '23 at 02:29