[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] basename for n levels
From: |
Eric Blake |
Subject: |
Re: [Help-bash] basename for n levels |
Date: |
Wed, 10 Jun 2015 06:29:46 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
On 06/09/2015 10:32 PM, Peng Yu wrote:
> Hi,
>
> The following thread shows for n = 2. Does anybody know what might be
> the most efficient and robust way to extract last n levels in bash?
>
> http://stackoverflow.com/questions/8223170/bash-extracting-last-two-dirs-for-a-pathname
Please try harder to make your questions self-contained. Making people
chase down a URL is not as nice as directly pasting the code in question:
> I seem to have failed at something pretty simple, in bash. I have a string
> variable that holds the full path to a directory. I'd like to assign the last
> two directories in it to another string. For example, if I have:
>
> DIRNAME = /a/b/c/d/e
>
> I'd like:
>
> DIRNAME2 = d/e
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Help-bash] basename for n levels, Peng Yu, 2015/06/10
- Re: [Help-bash] basename for n levels, Dennis Williamson, 2015/06/10
- Re: [Help-bash] basename for n levels, Peng Yu, 2015/06/10
- Re: [Help-bash] basename for n levels, Greg Wooledge, 2015/06/10
- Re: [Help-bash] basename for n levels, Peng Yu, 2015/06/10
- Re: [Help-bash] basename for n levels, Peter West, 2015/06/10
- Re: [Help-bash] basename for n levels, Greg Wooledge, 2015/06/10
- Re: [Help-bash] basename for n levels, Stephane Chazelas, 2015/06/10
- Re: [Help-bash] basename for n levels,
Eric Blake <=