0
I am trying to extract lines from a file and save the output to a new file.
I have been using the code:
cat datafile | awk -f pullhh.txt > fuel
where the file pullhh.txt
contains the code /FUELHH/
I want to extract lines containing the word FUELHH
and save them to a file and then also extract lines containing FUELINST
and save them to a separate file.
Is there a way to do this having both commands in the pullhh.txt
file?
You don't need a script file at all, just write
awk '/FUELHH/ || /FUELINST/' datafile > fuel
as glenn suggests – terdon – 2013-01-15T15:18:08.543@terdon: what about
and save them to a separate file
? – sparkie – 2013-01-16T03:36:37.517@sparkie, indeed, missed that, thanks, see my answer. – terdon – 2013-01-16T11:57:23.243