Skip to main content

You can use tee and process substitution for this:

cat file.txt | tee >(pbcopy) | grep errors 

This will send all the output of cat file.txt to pbcopy, and you'll only get the result of the grep on your console.

You can put multiple processes in the tee part:

cat file.txt | tee >(pbcopy) >(do_stuff) >(do_more_stuff) | grep errors 

You can use tee and process substitution for this:

cat file.txt | tee >(pbcopy) | grep errors 

This will send all the output of cat file.txt to pbcopy, and you'll only the result of the grep on your console.

You can put multiple processes in the tee part:

cat file.txt | tee >(pbcopy) >(do_stuff) >(do_more_stuff) | grep errors 

You can use tee and process substitution for this:

cat file.txt | tee >(pbcopy) | grep errors 

This will send all the output of cat file.txt to pbcopy, and you'll only get the result of grep on your console.

You can put multiple processes in the tee part:

cat file.txt | tee >(pbcopy) >(do_stuff) >(do_more_stuff) | grep errors 
Source Link
Mat
  • 54.9k
  • 11
  • 164
  • 143

You can use tee and process substitution for this:

cat file.txt | tee >(pbcopy) | grep errors 

This will send all the output of cat file.txt to pbcopy, and you'll only the result of the grep on your console.

You can put multiple processes in the tee part:

cat file.txt | tee >(pbcopy) >(do_stuff) >(do_more_stuff) | grep errors