Skip to main content

cut, sort, uniq: Simple Text Tools

cut extracts fields. sort sorts. uniq finds unique. Simple tools.

Here's the thing: These tools are simple. But useful. Learn them.

cut

cut -d: -f1 /etc/passwd

My take: cut extracts fields. Use it.

sort

sort file.txt
sort -r file.txt # Reverse

My take: sort sorts lines. Use it.

uniq

sort file.txt | uniq

My take: uniq finds unique. Sort first.

Common Patterns

Combine

cut -d: -f1 /etc/passwd | sort | uniq

What's Next?

Now that you understand these tools, let's talk about Text Processing Examples.


Personal note: These tools seemed simple. Then I used them. Now I use them constantly. They're useful. Learn them.