I need to trim the header in a csv file. I have used tail -n +2 ...
which works fine but it is really slow (I have lots of 100M files), and I don't understand why since no memory is needed from tail to achieve this (unlike tail -n 10000
for instance).
I have tried awk '{if (NR > 1) print $0}'
. It is a bit faster but still orders of magnitude slower than cat
. But cat
doesn't have that option.
Are there other commands? Thanks
{ head -n 1 >/dev/null; cat; } <infile
though that won't work with allhead
s so you might as well try{ sed -n 1q; cat; } <infile
... – don_crissti Jun 20 '17 at 09:39cat
does and it is 100x faster – Thomas Jun 20 '17 at 09:46sed
worked for me, not sure whyhead
doesn't. And it is really fast, thanks! if you want to write it as an answer, please do – Thomas Jun 20 '17 at 09:47{ read -r line; cat; } <file
– George Vasiliou Jun 20 '17 at 09:52