Re: sh: getting <category>/<portname> from pwd
- Reply: Eugene Grosbein : "Re: sh: getting <category>/<portname> from pwd"
- In reply to: Nuno Teixeira : "sh: getting <category>/<portname> from pwd"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 26 Oct 2022 04:31:07 UTC
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.