The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 awk again
Author: Alan Anderson 
Date:   28-10-01 18:43

(posted by Dan Langille)

I think awk has a reasonable learning curve, especially to new users, so its good to see examples of awk. Especially since this is where awk shines.

Here is the awk way:

( print the first field of any line that does not have a pound sign in it. )
awk -F: '!/#/ { print $1 }' /etc/passwd


(print lines where a comment does not exist in field 1)
awk -F: '$1 !~ /#/ { print $1 }' /etc/passwd

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org