Reputation: 205
I'd like to filter the content of /etc/passwd
, only showing the lines for which the value in the third column is greater than 999
.
Is there an easy way to do this with a one liner? I'd like to do it without writing a boring for-loop
.
Upvotes: 3
Views: 541
Reputation: 7058
This is a simple way to do it:
awk -F: '$3 > 999' /etc/passwd
This uses awk
with a field separator of :
and instructs it to print the line if the third field is greater than 999. If you want to only print the first field (username) or construct some new lines based on the fields, this is a starting point:
awk -F: '{if ($3 > 999) print "user", $1, "uid", $3}' /etc/passwd
Upvotes: 8