Questions tagged [tr]

tr is a *nix utility for character-level alterations to a stream. tr/// is a Perl operator named after this utility. For the tag used to build HTML tables, please use [html-table]. Use this tag only if your question relates to programming using tr. Questions relating to using or troubleshooting tr command-line options itself are off-topic.

tr (for "translate") is a standard utility in Unix, GNU/Linux, and other systems. It reads from standard input and writes to standard output, making specified character-level alterations.

One alteration it can make is to substitute individual characters, or groups of characters, with specified replacements; for example, tr a-z A-Z "translates" every occurrence of a lowercase ASCII letter to its uppercase counterpart.

Another alteration is to remove characters; for example, tr -d % "deletes" every instance of a percent sign, while tr -s % "squeezes" sequences of repeated percent signs (so that %% or %%% or %%%% or whatnot will become simply %). tr can also complement characters; for example, tr -cd '[:alnum:]' removes all non-alphanumeric characters.

tr/// is a Perl operator named for this utility. (It can also be written y///, after the same operator in sed.) It substitutes individual characters; for example, tr/a-z/A-Z/ translates every occurrence of a lowercase ASCII letter to its uppercase counterpart.

Beginners often try to use tr for replacements which are not character-level alterations. If you don't want to replace every instance of an individual character with something else, this is the wrong tool; perhaps look at sed, or the s/regex/string/ facility in Perl for regular expression (text pattern) replacement.

Links

675 questions
-1
votes
2 answers

HTML Table Problem: Static width with display:block and variuos text length

actually i got a problem with the view of a table. I need a horizontal scrollbar in my . For this i found here a solution:
-1
votes
2 answers

Shell command pr

How do I edit command pr tr [:upper:] [:lower:] < "${FILE}" | tr -d [:digit:] | sort | pr -s' ' -t3 | nl so that the output looks like this: 1 bcxwhex jbdafn osnu 2 bijly jdofnx uriqcl 3 btgr jz uztyp 4 bwifmn kfaky wfwdz 5 …
user14725090
-1
votes
3 answers

Shell command - tr,sort,paste,nl

I have this assignment The FILE variable is the name of a text file that contains exactly 30 lines. Each line consists of just one word, consisting of uppercase and lowercase letters and numbers. Change this file so that all digits disappear from…
Aaron7
  • 277
  • 2
  • 10
-1
votes
1 answer

Bash - Correct number in indian Phone Number format

I have a csv 18th column has indian phone numbers. +91 8889990098 +91 888999009 +91 88899900981 889990098 8889990098 +1 77799888999 +91 0189990098 +91 118999009 +91 44899900981 All i need correct Indian Mobile numbers from above numbers list…
Amit Singh
  • 188
  • 9
-1
votes
1 answer

VBA Get webpage Link and Download File to

Is a long time ago to programming VBA. I want to fetch in a web Table all Linked PDF Files in coll um (x). First I have created the logins and navigate to the site to fetch file. Site table: Sub goToShopWH() Dim ieApp As InternetExplorer Dim…
-1
votes
3 answers

Why is translate working and not sed for line feed

I would like to replace linefeed by something else like # I have tried sed but \n doesn't work and \x0a as well I got file z1 cat z1|hd 00000000 30 0a 61 0a 0a 31 0a 62 0a 0a 32 0a 63 0a |0.a..1.b..2.c.| and if i try cat z1|sed…
innerjoin
  • 3
  • 4
-1
votes
1 answer

Pyside qwebenginWidget no open QWebenginProsser

I tried to open the web like the article below in pyside2, all that can be displayed is that the applicon cannot open the web. How to detect button click inside Qwebengine in pyside2
Vologa
  • 1
  • 2
-1
votes
1 answer

usding sed to replace multi-words

Is there an example of if you want to replace multi-words with one word for example input: dog apple orange banana pear output dog cat cat banana cat I have solved with this below is there is a better way(better than sed)? by not typing cat three…
-1
votes
2 answers

Javascript to get text node of td using tr class

I have the following codes below:
... [Multiple lines ommited for brevity]
 Archives, Thesis Col. Graduate, 12F (Mezz.) Henry Sy Sr. Hall