help-bash
[Top][All Lists]
Advanced

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

Re: Removing last directory from path


From: Seth David Schoen
Subject: Re: Removing last directory from path
Date: Thu, 14 Oct 2021 19:20:29 -0700

tolugboji writes:

> On Friday, October 15th, 2021 at 1:29 AM, Chris F.A. Johnson 
> <chris@cfajohnson.com> wrote:
> 
> > On Fri, 15 Oct 2021, tolugboji via wrote:
> >
> > > I have a path gmtbin, and would like to remove the /bin at the end.
> > >
> > > gmtbin="/usr/local/bin/gmt/bin"
> >
> > binless=${gmtbin%/bin}
> 
> Right, I was using ${gmtbin/\/bin/}, which was removing the two /bin.

For directory paths in particular, you could also use dirname.  It
removes only the last path component.



reply via email to

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