8

new to Ubuntu was wondering if anyone can explain why one only shows the user and username and the other shows more information? what's the difference between $USER and USER

1 Answer 1

15

In the first form,

env | grep $USER

The variable $USER is expanded to its value for grep. So, grep will show all lines which contains the value of $USER variable. For me, the value of $USER is anwar. So the command is equivalent to env | grep anwar

If you want to grep the literal $USER, use single quote as suggested in this answer

In the second form,

env | grep USER

only the literal USER is used for grepping and thus grep will only show those lines containing USER.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .