I made a script that uses du at some point, to show the space used into a directory. I want that to to be showed without the "/home/azarilh" in the string. I was trying to remove that with an example...
What i have:
5G /home/azarilh/folder/asd
What i want to get:
5G /folder/asd
I have tried (using echo instead of du as an example):
echo "5G /home/azarilh/folder/asd" | sed -e 's/\<\/home\/azarilh\>//g'
Would be better to get "~/folder/asd" instead of just removing "/home/azarilh". Doesn't need to be sed, i have tried with grep but with no success. I use grep to remove prefixes and it works.
echo "$string" | grep -oP "^$prefix\K.*"
Maybe it can be modified to work in this case?