I\'m really new with bash, but it\'s one of the subjects on school. One of the exercises was:
Give the line number of the file \"/etc/passwd\" where the informat
You can do this with a single awk
invocation:
awk -v me=$(whoami) -F: '$1==me{print NR}' /etc/passwd
In more detail:
-v
creates an awk
variable called me
and populates it with your user name.-F
sets the field separator to :
as befits the password file.$1==me
only selects lines where the first field matches your user name.print
outputs the record number (line).