Sample Header Ad - 728x90

parsing variable which contains vertical bar

0 votes
2 answers
1204 views
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: /dev/sde| name0|name1|name2| 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.
Asked by Botspot (161 rep)
Feb 11, 2020, 01:40 PM
Last activity: Feb 11, 2020, 07:27 PM