Re: Extracting path components from an absolute path
On May 29, 12:45 pm, fia_wrc_fanatic <fia_wrc_fana...@yahoo.com>
wrote:
> I am trying to write a Bash script that extracts some or all of the
> path components from an absolute path.
> For example, if I have the following absolute path:
>
> INSTALLROOT=/opt/vendor/product/
>
> I need to be able to extract the first path component ("opt" from the
> example above), as well as the remaining string ("vendor/product" from
> the example above).
>
> What's the best way to do this from a Bash script?
Would this be what you are looking for?
echo ${INSTALLROOT%/*/*} ${INSTALLROOT#/*/}
|