I am very new to awk and I am trying to sort the fifth group of my usernames which has " Zack e" in alphabetical order. I typed getent passwd
in my terminal, which are:
zack:x:115:120:Zack E:/home/zack:/var/run/bin/bash/false
hp:x:118:7:HPLIP system user:/var/run/hplip:/bin/false
armvad:x:3:3:Ezikon Armvad:/dev:/usr/sbin/nologin
bruh:x:1542:1546:Burh RG:/home/banner:/bin/bash
I also tried this approached
for i in `sed -e 's/.* \(\d\)*/\1/' passwd.in | sort`; do grep $i passwd.in; done > file_sort.txt
But all it did was sort the first group instead of the desired group. How can I combine my approach with an awk script all I know to do in awk is BEGIN {FS = ":"} $5 == 1000{print $1}
Is there any way, I can rearrange the tokens so sort can work, and then put them back in order?