I have a small problem and I would appreciate helping me in it.
In summary, I have a file:
1,5,6,7,8,9
2,3,8,5,35,3
2,46,76,98,9
I need to read specific lines from it and print them into another text document. I know I can use (awk '{print "$2" "$3"}') to print the second and third columns beside each other. However, I need to use two statement as (awk '{print "$2"}' >> file.text) then (awk '{print "$3"}' >> file.text), but the two columns would appear under each other and not beside each other.
How can I make them appear beside each other?
If you must extract the columns in separate processes, use
pasteto stitch them together. I assume your shell is bash/zsh/ksh, and I assume the blank lines in your sample input should not be there.produces
Without the process substitutions:
Update based on your answer:
On first appearance, that’s a confusing setup. Does this work?
That has to read the file.txt file a number of times. It would clearly be more efficient to only have to read it once: