Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I go about doing this:

Using the sort, grep and less commands (connected with a pipe), sort the /etc/passwd file in alphabetical order and display only the lines ending in the word "false".

share|improve this question
Is this homework? – innaM Nov 30 '09 at 10:01
Apparently so. HardwareMuch even tagged it that way. – Doug Harris Nov 30 '09 at 18:45
Yes it is, Manni, hence the 'homework' tag :) – Phoshi Nov 30 '09 at 18:45
Indeed! well, duh! – innaM Dec 4 '09 at 21:41
up vote 6 down vote accepted
grep false$ /etc/passwd | sort | less
share|improve this answer
+1, It would be a little more correct to use sort -t:. But this works on /etc/passwd. – nik Nov 30 '09 at 5:03
Hm, yeah, I guess you don't need the ^.* ... – Lawrence Velázquez Nov 30 '09 at 5:04
For better performance, you should do grep first, then sort. – Kim Nov 30 '09 at 5:11
You didn't use less here. – innaM Nov 30 '09 at 10:01
all comments taken into consideration, answer updated. – John T Nov 30 '09 at 18:25

I just tried this on Mac OS X 10.6, but I feel that it should work on Linux also:

sort /etc/passwd | grep '^.*false$' | less
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .