I have several tsv files in a folder which add up to over 50 gb total. To make it easier on memory when loading these files into R, I want to extract only the first 3 columns of these files.
How can all of the files have their columns extracted at once in terminal? I am running Ubuntu 16.04.
This looks like a perfect use case for the cut
utility
You can use it as follows:
cut -d$"\t" -f 1-3 folder/*
Where -d
specifies the field delimiter (in this case tabs), -f
specifies the fields to extract and folder/*
is a glob specifying all files to be parsed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With