Remove first directory components from path of file
I need to remove one directory (the leftmost) from variables in Bash. I found ways how can I remove all the path or use dirname and others but it was removing all or one path component on the right side; it wouldn't help me. So you have a better understanding of what I need, I'll write an example: I have a/project/hello.c , a/project/docs/README , ... and I want to remove that a/ so after some commands I´ll have project/hello.c and project/docs/README , ... You can use any of: x=a/b/c/d y=a/ echo ${x#a/} echo ${x#$y} echo ${x#*/} All three echo commands produce b/c/d ; you could use the value