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
Check command substitution in the bash
man page.
You can you back ticks ``
or $()
, and personally I prefer the latter.
So for your question:
grep -n -e $(whoami) /etc/passwd | cut -f1 -d :
will substitute the output of whoami
as the argument for the -e
flag of the grep
command and the output of the whole command will be line number in /etc/passwd
of the running user.