I\'m trying to remove part of the path in a string. I have the path:
/path/to/file/drive/file/path/
I want to remove the first part /
If you want to remove the first N parts of the path, you could of course use N calls to dirname
, as in glenn's answer, but it's probably easier to use globbing:
path=/path/to/file/drive/file/path/
echo "${path#*/*/*/*/*/}" # file/path/
Specifically, ${path#*/*/*/*/*/}
means "return $path
minus the shortest prefix that contains 5 slashes".