Questions tagged [tr]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
7
votes
4answers
333 views

How would you separate fields with multiple spaces and store them in an array?

In my file mytxt: field1 field2 ------ ------- this are numbers 12345 this letters abc def ghi Let's say I want to store the first field ...
1
vote
1answer
36 views

Change characters to lowercase

I am trying to make all values in the 11th column of my .csv file lowercase. I know I can use 'tr A-Z a-z' but how do I make sure it is working in the file I want and only on the 11th column.
1
vote
3answers
148 views

CSV to TSV without replacing commas within quotes

All the CSV to TSV tutorials are suggesting a simple: tr ',' '\t' though some CSVs look like this: 1,310,"IntAct,PINA" in which case I would like to keep "IntAct,PINA": 1 310 "IntAct,PINA" How ...
7
votes
1answer
1k views

tr: command not found

I'm using Ubuntu 18.04, and recently I keep getting this error when running bash scripts: tr: command not found. The tr does not exists in /usr/bin and /usr/sbin. Also installed coreutils but still no ...
0
votes
0answers
83 views

Condition on the output to xterm of a variable that has been echo'ed in color

The fourth line of this code outputs the input argument in green color to an xterm. However, I'd like to be able to condition on the value of the input. If I input the word Foo then from bash's ...
1
vote
1answer
206 views

Using the tr command with character ranges

For the past few months, I've been learning about the command line with the help of William E. Shotts' The Linux Command Line. The Linux Command Line remains a popular book for newbies who would like ...
1
vote
3answers
1k views

Remove Control Return and merge lines in one text file and limit number of characters

I wan to remove Control Return and merge lines in one text file and limit number of characters input.txt containing: comment 1 comment 2 ... comment n output.txt should one strings: comment 1 ...
0
votes
1answer
48 views

Testing the limits of the tr command using character ranges

I'm trying to test the limits of the tr command using character ranges. What I don't get is how come I get the output: lowercase letters when typing: echo "lowercase letters" | tr A-Z A-Z instead ...
9
votes
2answers
5k views

How does tr translate one word to another?

I have a file ma.txt and it contains the output of ls -l; when I run the tr command (tr "nik-pc" "root") I get this output: nik-pc@nik:~$ cat ma.txt total 52 drwxr-xr-x 2 nik-pc nik-pc 4096 Mar 11 ...
1
vote
1answer
68 views

Ubuntu Server 14.04.3 update problems

using Ubuntu Server 14.04.3. apt-update & upgrade stuck on tr.archive.ubuntu.com It's responding so slow and can't download packages.
4
votes
3answers
2k views

How I can count how many repeated numbers in a file and then organize them by repetitions?

I have a file that needs organized a number of repeats, my file has 6 rows and 3120 lines each member has 1 or 2 digits, total 18720 numbers with one or 2 digits. I would like to count how many 1, ...
0
votes
2answers
3k views

Looping tr command to remove '\r' in multiple files in a directory

I have about 260 files in a directory. How can I input these files one by one into some thing like this file is an array name file=input stream of multiple files x=0 LOOP tr -d '\r' file2 rm $file ...
8
votes
2answers
25k views

How can I add a backslash before all spaces?

How can I put a backslash before every space, preferably by using tr or sed commands? Here is my script: #!/bin/bash line="hello bye" echo $line | tr ' ' "\\\ " This is supposed to replace spaces ...