Linux – Get home directory by username

bashlinux

I want to obtain home dir of any user with echo

echo ~puchuu
>> /home/puchuu

But I cant use variable

echo ~$USER
>> ~puchuu
echo `echo ~$USER`
>> ~puchuu

Best Answer

You can use eval:

eval echo ~$USER

But see Andrew's comment and glenn's reply below.

Related Question