The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 02-03-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
cd ~ will not work on bourne shells (the default for many unix'es)

I'm assuming by 'anything except cd...' you mean it as it's written (ie cd with no options to get to the home dir).
In which case, cd $HOME should sort you out.

If you want something foolproof though:
Code:
cd `grep -e "^username:" /etc/passwd | cut -d ':' -f 6`

is the only real way to be certain.
Depending on the version of grep, you may need to use egrep, or omit the -e flag.