Date: Wed, 26 Oct 2022 11:31:07 +0700 From: Eugene Grosbein <eugen@grosbein.net> To: Nuno Teixeira <eduardo@freebsd.org>, FreeBSD Mailing List <freebsd-ports@freebsd.org> Subject: Re: sh: getting <category>/<portname> from pwd Message-ID: <d06cd71d-bb8b-192b-d927-0314ae544a11@grosbein.net> In-Reply-To: <CAFDf7UJp9PkrhfMmJRKO7QNTmGQYu7BQYyqczoz-Dy7hP3h74g@mail.gmail.com> References: <CAFDf7UJp9PkrhfMmJRKO7QNTmGQYu7BQYyqczoz-Dy7hP3h74g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
26.10.2022 5:14, Nuno Teixeira wrote: > Hello all, > > I'm writing a shell script to feed poudriere testports and I need to get <category>/<portname> from ports tree: > > `pwd`: > /home/user/work/freebsd/ports/<category>/<portname> > > `pwd | rev | cut -d / -f1,2 | rev` do the trick but it is so uggly! > > Is there a shell option to get it? Naturally, there is. cwd=$(pwd) echo ${cd##*/ports/} This is documented in sh(1) manual page, section "Parameter Expansion". No need to call external tools.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d06cd71d-bb8b-192b-d927-0314ae544a11>