I’ve got a comma separated textfile, which contains the column headers in the first line:
column1;column2;colum3
foo;123;345
bar;345;23
baz;089;09
Now I want a short command that outputs the first line and the matching line(s). Is there a shorter way than:
head -n 1 file ; cat file | grep bar
This might work for you:
Usually
cat file | ...is useless but in this case it keeps the file argument out of the way and allows the variablevto be amended quickly.Another solution: