0

I'm trying to kill and restart pulseaudio in verbose mode, I need to search in the output. I tried to use the pipe to grep the output. After that failed I tried to append the output to a file. I'm doing something wrong.

The kill and start command is

pulseaudio -k && pulseaudio -v

I'm trying to do something like this:

pulseaudio -k && pulseaudio -v | grep conf
(pulseaudio -k && pulseaudio -v) > 'aout.txt'
pulseaudio -k && (pulseaudio -v > 'aout.txt')

It still just displays the output as it is in the terminal. What am I doing wrong?

Note that I prefer to grep than to append to file.

1 Answer 1

3

You likely need to redirect the commands' standard error as well e.g. (using bash command grouping, so as to capture both commands error streams with a single redirect)

{ pulseaudio -k && pulseaudio -v ; } 2>&1 | grep 'conf'

or using the shorthand |& operator

{ pulseaudio -k && pulseaudio -v ; } |& grep 'conf'

To redirect to a file

{ pulseaudio -k && pulseaudio -v ; } > aout.txt 2>&1

(note the order of redirections) or its semantic equivalent

{ pulseaudio -k && pulseaudio -v ; } &> aout.txt 2>&1

See the REDIRECTION section of man bash

2
  • yes that works for grep but the append isn't working. I'm trying { pulseaudio -k && pulseaudio -v; } 2>&1>'aout.txt' Mar 16, 2017 at 17:47
  • { pulseaudio -k && pulseaudio -v; }>'aout.txt' 2>&1 got it! thank you very much!!! cheers :D Mar 16, 2017 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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