Question Details

No question body available.

Tags

text replace whitespace git-bash tr

Answers (2)

Accepted Answer Available
Accepted Answer
January 12, 2026 Score: 2 Rep: 10,802 Quality: High Completeness: 50%

tr only does character by character translation. Every input character is mapped to exactly one output character. Because your search set contains a single character (';'), tr can only replace it with one character. In echo 'Hello;World' | tr ';' '\\ ' , the replacement set ('\\ ') has two characters (backslash + space). tr takes the first one (\) to translate ;, so you get Hello\World.

Ideally you should use sed like echo 'Hello;World' | sed 's/;/\\ /g' or printf like printf '%s\n' 'Hello;World' | sed 's/;/\\ /g'

January 12, 2026 Score: 2 Rep: 14,553 Quality: Low Completeness: 40%

cut command could also be used as

cut -d ';' --output-delimiter='\ ' -f 1-