awk command: print output to specific column in new file

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Pangolin
Level 3
Level 3
Posts: 150
Joined: Sat Sep 12, 2015 4:16 pm

awk command: print output to specific column in new file

Post by Pangolin »

Hi.
I need to sum the integer values contained in column n. 1 of file VALUES.cvs and print the result into file RESULT.csv but in column n. 3.
How can I achieve that?
My knowledge of the awk command just ends here:

Code: Select all

awk '{sum += $1} END {print sum}' VALUES.csv > RESULT.csv
but it obviously prints the result in the first column of RESULT.csv
Any ideas?
Thank you.
Last edited by LockBot on Wed May 10, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
I'm here thanks to Windows 10
1000
Level 6
Level 6
Posts: 1040
Joined: Wed Jul 29, 2020 2:14 am

Re: awk command: print output to specific column in new file

Post by 1000 »

This is not a direct solution.
https://stackoverflow.com/a/9506868


Problems:
- I much prefer bash
- " values contained in column n. 1 "
I don't see example.
* I don't see if they are separated by a space or something else.
* If there is only one number in the first column, then where is the next number?
Locked

Return to “Other topics”