env | grep $USER vs env | grep USER
Solution 1:
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
.