Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
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
add comment

2 Answers

up vote 5 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
8  
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
add comment

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
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.