Reputation: 9658
When I use pwd
it returns:
/home/ahmad/multifit-pretrain-lm/multifit/datasets
I look for a command so that I get the path relative to the home directory
multifit-pretrain-lm/multifit/datasets
Upvotes: 3
Views: 2710
Reputation: 6134
Variable substitution is a good solution but since you asked for a command, here is one:
realpath --relative-base="$HOME" .
Upvotes: 2
Reputation: 785156
I look for a command so that I get the path relative to the home directory
You can use bash parameter substitution here:
echo "${PWD#"$HOME"/}"
$PWD
shell variable returns same value as the command pwd
${PWD#"$HOME"/}
strips "$HOME"/
at the start from $PWD
Upvotes: 5