I need to remove the part
man1/bmtoa.1.gz
from the full path
/usr/share/man/man1/bmtoa.1.gz
so that it results in
/usr/share/man/
I've tried ${path#[!/]*/*} and ${path#/*/*} but both result in wrong paths.
I need to remove the part
man1/bmtoa.1.gz
from the full path
/usr/share/man/man1/bmtoa.1.gz
so that it results in
/usr/share/man/
I've tried ${path#[!/]*/*} and ${path#/*/*} but both result in wrong paths.
this will work ${path%/*/*}
, but works from the back to the front. here is a good how-to for chopping strings in bash.
If you could deal with /usr/share/man/man1
, then you could do dirname /usr/share/man/man1/bmtoa.1.gz
, but since you stated that you need the man1 to also come off, so you'll have to daisy-chain them:
dirname `dirname /usr/share/man1/bmtoa.1.gz`