Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What is the benefit of -s or --squeeze-repeats when we use tr? What practical usage?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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*]').

share|improve this answer
add comment

How to make the 'cut' command treat several sequential delimiters as one?

$ cat text.txt | tr -s " " " " | cut -d " " -f 4
share|improve this answer
1  
< text.txt tr -s ' ' | cut -d' ' -f 4 is shorter: it leaves out the unnecessary second argument to tr and the UUOC. –  jw013 Feb 14 '12 at 16:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.