Tim Van Wassenhove

Passionate geek, interested in Technology. Proud father of two

06 Jul 2005

GNU text utilities

More and more i seem to recieve requests from people that need to manipulate some text files.

And they do not feel like doing it manually. So here are some examples of how i used the

GNU text utilities:

I want to split the file below into one with the questions and one with the answers. This can be easily done:

cut -d '.' -f1 trivia.txt > questions.txt
cut -d '*' -f2 trivia.txt > answers.txt

I want to know how many times people have logged in. With last i recieve output like below.

I generate a top10 list:

last | cut -d ' ' -f1 | sort | uniq -c | sort -rn | head

I want to use this file to generate two files, one for small galleries (<10 photos) and one for large galleries (>= 10 photos)

grep -E '(.*?)\|[0-9]{1}' galleries.txt > small.txt
grep -vE '(.*?)\|[0-9]{1}' galleries.txt >large.txt