I have quite a large csv file (call it file.csv). It looks like this one:col1,col2,col3,...1,2,31,2,5...So after doing something like this cat file.csv | grep _some_pattern_ I receive only the output values. Is there a way to append the header (the first line) to the output? It would be very convenient...
Is there a way to append a header to a grepped output?
bash;grep
you can use head to print the first line and tail to search with grep starting after the header for the pattern.head -n 1 file.csv && tail -n +2 file.csv | grep some pattern