Reputation: 4840
ROOT=`pwd | sed 's%\(.*/myABC\)/.*%\1%'`
This is a shell command , I believe the purpose is to find root path of this project. I am not so sure how this work. Could anyone help explain it for me? Thank you so much
Upvotes: 2
Views: 3111
Reputation: 2081
you are in the directory path
/home/youruser/myABC/some/other/deeper/dir and you use these command the path will be truncated to only /home/youruser/myABC/.
sed - is a string editing tool
s% - substitute the string of pwd and use '%' as separator
\(.*/myABC\)/.* - capture a string which contains myABC and save this in the first parameter
\1 - print first parameter
best regards kenny
Upvotes: 3
Reputation: 143966
If you want the parent directory of the current directory, couldn't you just do:
ROOT=`dirname $PWD`
Upvotes: 1