Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
Is there any reason that you can not use pipes? | – Hennes Nov 23 '13 at 16:27
    
no 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 Nov 23 '13 at 16:47
1  
You might even go further and combine the awk scripts in a single one. – jlliagre Nov 23 '13 at 17:10

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 acutally do), the line gets even shorter:

awk script123 output.txt > Final_output.txt
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.