Skip to main content

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.

-1 votes
1 answer
111 views

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 &...
Richard Barraclough's user avatar
-1 votes
2 answers
7k views

I was playing around with tr and got some unexpected results. What is happening in these situations? I don't understand what is happening under the hood, or perhaps I'm not using this command ...
BadHorsie's user avatar
  • 141
2 votes
0 answers
137 views

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'...
sudocracy's user avatar
  • 231
0 votes
1 answer
125 views

I need help with a script that mv (renames) filenames that are shown with single quotes in ls output or files that require single quotes for file operations. The script will be used to rename all ...
Psilospiral's user avatar
5 votes
1 answer
476 views

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" ...
AdminBee's user avatar
  • 23.7k
0 votes
2 answers
240 views

The top answer to this question demonstrates that cut can be used with tr to cut based on repeated spaces with < file tr -s ' ' | cut -d ' ' -f 8 I want to get the remotes of several Git repos in ...
Anil's user avatar
  • 221
0 votes
1 answer
256 views

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 ...
Abhishek A Udupa's user avatar
5 votes
3 answers
631 views

I am debugging an embedded server that outputs a continuous single line of text to a specified network port. There is no newline anywhere in the stream but it is text data and I would like to format ...
stmfunk's user avatar
  • 193
0 votes
5 answers
900 views

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 ...
C S Pallapu's user avatar
6 votes
1 answer
4k views

I have a string animal: dog and I would like to transform to have just animal dog (one space between). e.g: echo 'animal: dog' | tr ':' ' ' animal dog There's 2 spaces above. I tried making the ...
Doug Fir's user avatar
  • 173
0 votes
0 answers
39 views

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,...
ardabro's user avatar
  • 159
0 votes
1 answer
300 views

I am new to trying to write bash functions, so maybe I'm doing something wrong, but when I execute: myfile=test.txt cat $myfile 2>&1 | tee "cat_$(echo "$myfile" | tr . _)_$(date +...
Joe's user avatar
  • 103
3 votes
2 answers
780 views

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 ...
Shriram's user avatar
  • 226
2 votes
2 answers
1k views

in order to isolate the last word in any line of a poem (to have a list of all rhymes), I put together several snippets of code obtaining this awk '{print $NF}' input.txt | tr 'A-Z' 'a-z' | tr -sc 'a-...
Dingo's user avatar
  • 339
2 votes
1 answer
248 views

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 ...
ElTitoFranki's user avatar

15 30 50 per page
1
2 3 4 5
13