I have a bash script that involves the output of yad. By default, yad outputs its results separated by pipe characters "|".

I have a string variable output. Echoing it shows it contains this:


I want all those vertical bars changed to line breaks.

This does not work: echo "$output" | tr '|' '\n'
And neither does this: echo "$output" > /tmp/output; echo $(cut -d'|' -f1 < /tmp/output)
Both attempts result in only a line break being outputted. /tmp/output was created, and it contained two empty lines but not any text.

  • What shell are you using? Your tr command is working for me. Feb 11, 2020 at 13:51
  • 1
    If echo "$output" > /tmp/output produces a file that contains two empty lines, then there is something else going on with your variable; please edit your question to include the output of printf '%s' "$output" | xxd or similar Feb 11, 2020 at 14:12
  • Please edit your question and i) tell us your operating system. Your tr command should work, so if it doesn't, it might be specific to whatever tr your operating system uses. ii) Explain what actually happens when you run the tr. Just telling is it doesn't work isn't very helpful. How does it fail? Are there any errors? Does it just not do anything at all? iii) Clarify if your $output variable contains multiple lines, with newlines, or just one.
    – terdon
    Feb 11, 2020 at 14:40

2 Answers 2


Your tr should be fine.

Try to escape "\|"


I finally figured out what was going on: the variable was being set incorrectly. Shortened:

yad --plug=12345 --tabnum=1 &
yad --plug=12345 --tabnum=2 &
output="$(yad --notebook --key=12345)"
echo "$output"

$output appeared to have been echoed since the results were printed to the terminal.
But removing the echo had no effect. Then I realized that the first two commands were the ones outputting the data, not the third & outer yad command.
Moving output="$( to the start of the first yad command solved the problem of the empty variable.

And, I browsed through man yad and discovered that there is a cli flag for just what I wanted:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .