Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I need help understanding a awk Linux Command

What does awk -F: '!($3 < 512 && $4 < 30)' /etc/passwd do in Linux? I only find awk is a scripting language but cant understand all this is doing.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is shorthand for

awk -F: '!($3 < 512 && $4 < 30) { print; }' /etc/passwd

and means "show all lines where NOT (:-separated field #3 is less than 512 and field #4 is less than 30)" from /etc/passwd

With the help of man 5 passwd and DeMorgan’s law, this corresponds to "show the user account list where the user id is greater than 512 or the group id is greater than 30".

This logic is likely intended to only show human users on the system, since a common convention is to assign them higher UIDs than non-human, system users like apache and mysql.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading