I'd like to know how cat passwd | awk -F':' '{printf $1}' works. cat /etc/passwd is a list of users with ID and folders from root to the current user (I don't know if it has something to do with cat passwd). -F is some kind of input file and {printf $1} is printing the first column. That's what I've search so far but seems confusing to me.
Can anyone help me or explain to me if it's right or wrong, please?
This is equivalent to
awk -F: '{print $1}' passwd. Thecatcommand is superfluous as all it does is read a file.The
-Foption determines the field separator forawk. The quotes around the colon are also superfluous since colon is not special to the shell in this context. Theprintinvocation tellsawkto print the first field using$1. You are not passing a format string, so you probably meanprintinstead ofprintf.