several awk commands consecutively

0

I'm using awk command to extract some datas. The point is that I need to use awk command several times to extract all informations I need and each time when I'm using awk I need create a temp file. My structure looks as below:

awk script1 output.txt > temp1.txt
awk script2 temp1.txt > temp2.txt
awk script3 temp2.txt > Final_output.txt
rm temp1.txt temp2.txt

Is there a way to eliminate the temp files? to execute several commands consecutively?

lucas

Posted 2013-11-23T16:05:27.563

Reputation: 47

You might even go further and accept the answer that's been posted in the meantime. Best thing would have been to invite @Hennes to produce an answer out of his comment so you could accept it. This way, everyone will know that your question has been answered satisfactorily. – simlev – 2018-04-12T13:11:06.117

1Is there any reason that you can not use pipes? | – Hennes – 2013-11-23T16:27:53.333

1no reason. I'm new in Linux and I didn't know that's possible;-) Pipes are working, you helped me a lot, thank You! – lucas – 2013-11-23T16:47:08.470

2You might even go further and combine the awk scripts in a single one. – jlliagre – 2013-11-23T17:10:37.937

Answers

1

Your example can be executed using:

awk script1 output.txt | awk script2 | awk script3 > Final_output.txt

If you can combine the scripts (depends on what you will actually do), the line gets even shorter:

awk script123 output.txt > Final_output.txt

WeSee

Posted 2013-11-23T16:05:27.563

Reputation: 246