alex
alex

Reputation: 1439

pass one command to another one on the terminal

Look at the below code

awk '{print $1}' grep _Y myFile

I want to pass the result of grep _Y myFile to awk command . How to write that line correctly .

Upvotes: 0

Views: 58

Answers (3)

Jotne
Jotne

Reputation: 41460

Why not do all in one go:

awk '/_y/ {print $1}' myFile

Upvotes: 5

Thatoneguy
Thatoneguy

Reputation: 31

Maybe <() would work?

It sends the output of a command to another command as a file.

I.e. awk '{print $1}' <(grep _Y myFile)

Also great for use with diff

See this for more details.

Upvotes: 3

Avinash Raj
Avinash Raj

Reputation: 174796

Use pipe | symbol to redirect the output of prceeding command to the following command,

grep _Y myFile | awk '{print $1}' 

Upvotes: 2

Related Questions