cmd:tr 

removing CR-LF with tr 

tr -d '\015' < $OLDFILE > $NEWFILE
tr -d '\r' < $OLDFILE > $NEWFILE

Usage 

$ xset -q | grep bell
  bell percent:  50    bell pitch:  400    bell duration:  100
$ xset -q | grep bell | tr '[^0-9]' ' '
  bell percent:        bell pitch:         bell duration:
$ xset -q | grep bell | tr ':A-z' ' '
                 50                 400                    100
$ xset -q | grep bell | tr -s ':A-z' ' '
 50 400 100

Limitation 

: how to use tr to
: replace the following text:
:
: "thank%
: you"
:
: with "thank you".
> tr -s '%\n' ' '
>

Um, no. That will remove all but the first % and newline in the file, and collapse all multiple spaces to one space.

The *correct* answer is that it cannot be done with tr; the correct tool is sed:

sed '/^thank%$/{
N
s/^thank%\nyou$/thank you/
}'

Chris Mattern

NB, -d removes a set, not a sequence:

echo aabbccabcd | tr -d 'abc'

The result is not 'aabbccd', but merely 'd'

documented on: 2003.12.12 Fri