Questions tagged [tr]
For questions pertaining to tr, a utility that translates or deletes characters. Use this tag for questions about the tr utility itself, or questions about issues arising from its use.
193 questions
-1 votes
1 answer
85 views
sed and tr not replacing mystery control character
root@calleva:~# echo "f" > file root@calleva:~# f=$(<file) root@calleva:~# echo "$f" f root@calleva:~# echo "$f" | tr -c '[:alpha:]' '_' f_root@calleva:~# echo &...
2 votes
0 answers
115 views
The paste command is outputing tabs instead of new lines when used with process substitution
The first command below produces each number on a separate line, and I would expect the second command to do the same thing because the only difference between the two is that we are using echo '1 2 3'...
5 votes
1 answer
447 views
Why does 'tr' with '-c' option and set 2 extension add an unwarranted character to the end?
I wanted to use tr to substitute "illegal" characters in a string with a replacement character, where "illegal" characters are all outside of a set of "allowed" ...
0 votes
1 answer
232 views
Transforming a filename with 'tr' using RegEx doesn't work
I want to use the tr command to rename something like filename.ext to someName.ext. To do that I've tried echo "filename.ext" | tr -c ".a-z" "someName"` to replace the ...
0 votes
5 answers
863 views
How to merge lines in groups of three
I have a file containing the below pattern, up to 2000 lines. For every group of three lines, the pattern repeats with different numerical values, but text values at the beginning are common up to ...
0 votes
0 answers
38 views
Why tr redirected to dd unexpectedly cuts data stream? [duplicate]
I'm able to fill 1MB file with specific character like this: > tr '\0' '#' </dev/zero | dd of=1MB.bin bs=1k count=1024 1024+0 records in 1024+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied,...
3 votes
2 answers
751 views
tr command unable to process colour output piped from grep
I'm running macOS 12.3.1 I added a couple of lines to my .zshrc, viz. export GREP_OPTIONS='--color=always' export GREP_COLOR='1;35;40' After this, when I pipe grep output to tr, it returns the same ...
2 votes
1 answer
229 views
replace character only when it's not inside curly braces (sed, awk, tr, ...)
I have a string called "desktops" that look like this: desktops="1 2 %{F#990000}3%{F-} 4 5 6 7 8 9 0" The 6 digits after the "#" represent an RGB color, so the 3rd ...