What is the benefit of -s
or --squeeze-repeats
when we use tr
? What practical usage?
Asked
Active
Viewed 4,338 times
5

Majid Azimi
- 3,098
2 Answers
4
The GNU coreutils manual gives some example applications such as collapsing multiple newlines into one (tr -s '\n'
), or putting each word on its own line while removing punctuation at the same time (tr -cs '[:alnum:]' '[\n*]'
).

jw013
- 51,212
2
How to make the 'cut' command treat several sequential delimiters as one?
$ cat text.txt | tr -s " " " " | cut -d " " -f 4
< text.txt tr -s ' ' | cut -d' ' -f 4
is shorter: it leaves out the unnecessary second argument totr
and the UUOC. – jw013 Feb 14 '12 at 16:52