Filtering /etc/passwd in Unix
bash, unix
Solution
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
Problem
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`.