~/ learn/ comp-325/ cards/ Four routes to one file
1 of 9

Three commands that all print your home directory

Three commands that all print your home directory

Answer

echo $HOME echo ~ getent passwd "$(id -un)" | cut -d: -f6 cd && pwd

Four routes to one string. `$HOME` is a shell variable set at login; `~` is expanded by the shell from the same value; `getent` reads field 6 straight out of the password database, which is where the value came from in the first place; and `cd` with no argument goes home, so `pwd` then prints it.

Sarwar & Koretsky 3e ch4 §4.3, §4.4.3

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/b5e360a1-18ef-4404-821a-fc70fd14a644/flashcard utf-8 LF