[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Is there a way to combine $( and ${%}?
From: |
John McKown |
Subject: |
Re: [Help-bash] Is there a way to combine $( and ${%}? |
Date: |
Fri, 8 Dec 2017 07:22:33 -0600 |
On Fri, Dec 8, 2017 at 7:10 AM, Greg Wooledge <address@hidden> wrote:
> On Thu, Dec 07, 2017 at 09:58:34PM -0600, Peng Yu wrote:
> > Hi,
> >
> > I have the following commands. Is there a way to combine them into one
> command?
> >
> > x=$(readlink -e "$0")
> > x=${x%/*}
>
> x=$(readlink -e "$0") x=${x%/*}
>
> There you go. Now it's one command.
>
>
Works. But if the OP wants another technically correct, but worse, answer,
there is always:
x=$(readlink -e "$0" | sed -r 's|^(.*)/[^/]*$|\1|' )
--
I have a theory that it's impossible to prove anything, but I can't prove
it.
Maranatha! <><
John McKown