Bash: grep pattern from command output

后端 未结 3 511
南旧
南旧 2021-02-05 07:17

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

3条回答
  •  春和景丽
    2021-02-05 07:53

    cat /etc/passwd -n | grep `whoami` | cut -f1 
    

    Surrounding a command in ` marks makes it execute the command and send the output into the command it's wrapped in.

提交回复
热议问题