3

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

8

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.