1 / 6

translate characters - standard input .

Tr. translate characters - standard input. tr x y < namesAndNumbers.txt translated from x to y in file namesAndNumbers.txt tr can be used to produce more readable output. cut -d: -f1,6 /etc/passwd | tr : 't' this replaces one delimiter with another making it more readable.

ash
Download Presentation

translate characters - standard input .

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tr

  2. translate characters - standard input. • tr x y < namesAndNumbers.txt • translated from x to y in file namesAndNumbers.txt • tr can be used to produce more readable output. • cut -d: -f1,6 /etc/passwd | tr : '\t' • this replaces one delimiter with another • making it more readable.

  3. Octal values • these can be used with tr • tr : '\t' • tr : '\11‘ (ie \11 is tab \t) • this replaces 'space' with 'new line' • date | tr ' ' '\n' • date | tr ' ' '\12‘ (ie \12 is \n newline)

  4. Upper to Lower case • Upper to Lower case • tr '[A-Z]' '[a-z]' < names.txt • will convert upper case to lower case.

  5. tr -s option (squash) • tr -s ':' '\11' • this will replace multiple occurances of :::: • with a single tab. • tr -l ' ' ' ' < poem.txt • will remove multiple spaces • and replace with single spaces.

  6. tr -d option (delete) • tr can delete single characters. • tr -d ' ' < names.txt • will remove space from names.txt • can do same with sed • sed 's/ //g' names.txt • (s is subsitute, g is global)

More Related