tr Questions

2

Solved

I am reading some sql queries into a variable from db and it contains new line character (\n). I want to replace \n (new line) with space. I tried solutions provided on internet but was unsuccessfu...
Mcguire asked 29/8, 2016 at 5:2

19

Solved

I would like to remove all of the empty lines from a file, but only when they are at the end/start of a file (that is, if there are no non-empty lines before them, at the start; and if there are no...
Octosyllabic asked 9/9, 2011 at 9:20

11

Solved

Am trying to format the below actual output to get in the same line for each disks 0. ct1d0 <INTEL-ADDPF2KX076T9S-2CV1-6.19TB> /pci@4,0/pci8086,347c@4/e,487c@0/disk@1 /dev/chassis/SYS/DBP/H...
Zoo asked 24/3, 2023 at 10:11

4

Solved

my problem of today is to replace in a string like this --> 6427//6422 6429//6423 6428//6421 every // with a ,. I tried with different commands: finalString=${startingString//[//]/,} doesn't wor...
Sister asked 7/12, 2014 at 17:55

12

Solved

If I run the command cat file | grep pattern, I get many lines of output. How do you concatenate all lines into one line, effectively replacing each "\n" with "\" " (end with " followed by space)? ...
Matzo asked 22/3, 2013 at 21:27

7

Solved

To remove all newlines you could, say: tr -d '\n' < days.txt cat days.txt | tr -d '\n' but how would you use tr to remove just the newline at the end/bottom of a text file? I'm not sure to s...
Mucor asked 3/5, 2013 at 18:12

8

Solved

What is the Windows equivalent of the tr command in Linux? For example, tr can replace all colons with a newline character. Can this be done in Windows? $ echo $PATH | tr ':' '\n' /usr/local/bin ...
Juback asked 27/3, 2015 at 1:48

6

Solved

Currently when I run a grep command on a visitors group that I had created grep visitors:x:1011: /etc/group This is a sample result of the above command, as the actual result is too long. visitors...
Tune asked 19/10, 2021 at 5:35

3

Solved

I would like to use the tr command to replace all occurrences of the string "\n" with a new line (\n). I tried tr '\\n' '\n' but this just seems to match any '\' and any 'n'
Conducive asked 28/11, 2012 at 17:10

2

Solved

I'm trying to extract a word list from a Russian short story. #!/bin/sh export LC_ALL=ru_RU.utf8 sed -re 's/\s+/\n/g' | \ sed 's/[\.!,—()«»;:?]//g' | \ tr '[:upper:]' '[:lower:]' | \ sort | uniq...
Espionage asked 14/11, 2012 at 15:25

2

Solved

I have this following data set in one file (.txt file) data1 = 275736 490;data11 = 87551 1004; data2 = 344670 4875; data3 = 472996 840;data4 = 0 0;data = 19708 279;data6 = 10262 18;data7 = 0 0;data...
Miniskirt asked 31/3, 2021 at 4:57

8

Solved

I'm trying to split sentences in a file into separate lines using a shell script. Now I would like to split the strings by !, ? or . . The output should be like this : The file that I want to read ...
Kempis asked 16/12, 2020 at 9:3

3

Solved

I'm doing a bash script and I have a problem. I would like to change the position of two characters in a string. My input is the following: "aaaaa_eeeee" The desired output is: "eee...
Godard asked 2/9, 2020 at 20:58

2

Please try the following commands: echo "(After Sweet Memories) Play Born To Lose Again" | tr '(' '-' | tr ')' '-' | tr ' ' '-' -After-Sweet-Memories--Play-Born-To-Lose-Again (notice the ...
Typesetter asked 11/8, 2020 at 6:28

1

I have a file that contains strings with newlines, like this: {"name": "John\n\nMeyer"} {"name": "Mary\n\nSmith"} How can I remove them using the tr tool? I'm trying this, but the output is ba...
Aloke asked 14/3, 2020 at 2:0

4

Solved

I have multiple .txt files containing text in an alphabet; I want to transliterate the text into an other alphabet; some characters of alphabet1 are 1:1 with those of alphabet2 (i.e. a becomes e), ...
Tombaugh asked 16/8, 2014 at 8:46

5

Let's suppose I have this variable: DATE="04\Jun\2014:15:54:26" Therein I need to replace \ with \/ in order to get the string: "04\/Jun\/2014:15:54:26" I tried tr as follows:...
Quillan asked 6/6, 2014 at 8:45

2

I have a question about removing invisible characters which can be only be seen when we try to view the file using "vi" command. We have a file that's being generated by Datastage Applica...
Deil asked 6/8, 2015 at 2:53

3

Solved

I have a lot of text in lowercase, only problem is, that there is a lot of special characters, which I want to remove it all with numbers too. Next command it's not strong enough: tr -cd '[alpha]...
Stylographic asked 28/4, 2016 at 23:12

2

Solved

I wrote the following to convert something like foo-bar-baz to FooBarBaz sed -r 's/^(.)|-(.)/\U\1\U\2/g' (Feel free to correct the above if there is something wrong) However, it does not work w...
Borak asked 3/6, 2018 at 16:33

2

Solved

I am trying to make tr -d remove a string of characters from an existing string, without it removing characters everywhere else. For example, I want tr to remove : OK from the end of every string i...
Chronological asked 29/3, 2018 at 19:11

3

I would like to know if there is an equivalent to tr/// (as used in Perl) in Java. For example, if I wanted to replace all "s"s with "p"s in "mississippi" and vice versa, I could, in Perl, write #...
Krute asked 17/9, 2011 at 21:23

3

I am having trouble loading a space delimited text file into a table. The data in this text file is generated by teragen, and hence, is just dummy data, where there are only 2 columns, and the firs...
Ichnite asked 7/1, 2014 at 22:50

3

Solved

So I was searching around and using the command tr you can convert from lower case to upper case and vice versa. But is there a way to do this both at once? So: $ tr '[:upper:]' '[:lower:]' or $ ...
Dissociate asked 20/4, 2014 at 5:25

4

Solved

So Im removing special characters from filenames and replacing with spaces. I have all working apart from files with single backslashes contained therein. Note these files are created in the Finde...
Nowicki asked 8/11, 2016 at 14:57

© 2022 - 2024 — McMap. All rights reserved.