Getting a User’s Home Directory in Bash
The tilde expansion ~username works fine when the username is literal, but fails when the username is stored in a variable like ~$user. Bash doesn’t perform tilde expansion on variables by default—it only expands ~ at the beginning of a word before variable expansion happens. Using eval The most common approach is to use eval:…
