help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] basename for n levels


From: Peng Yu
Subject: Re: [Help-bash] basename for n levels
Date: Wed, 10 Jun 2015 08:33:07 -0500

For example:

If the input string is a////b///c///d//e, and n=3, the output should be c/d/e.

If n=4, the output should be b/c/d/e.
If n>=5, the output should be a/b/c/d/e.

If the input string is ///a////b///c///d//e, and n=3, the output
should be c/d/e.

If n=4, the output should be b/c/d/e.
If n=5, the output should be a/b/c/d/e.
If n>=6, the output should be /a/b/c/d/e.


On Wed, Jun 10, 2015 at 7:58 AM, Greg Wooledge <address@hidden> wrote:
> On Wed, Jun 10, 2015 at 07:54:59AM -0500, Peng Yu wrote:
>> On Wednesday, June 10, 2015, Dennis Williamson <address@hidden>
>> wrote:
>> > or you can use read and an array
>> >
>> > IFS=/ read -a parts <<< "$var"
>> >
>>
>> This is not robust wrt multiple consecutive slashes.
>
> Demonstrate the failure.  Give an example input, the desired output, and
> the actual output.



-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]