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
You can use eval:
eval
eval echo ~$USER
This might work for you:
homedir=$( getent passwd "$USER" | cut -d: -f6 )
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the privacy policy and terms of service.
tagged
asked
7 months ago
viewed
249 times
active