[GRASS-dev] Re: [GRASS GIS] #181: tac command missing in OSX
GRASS GIS
trac at osgeo.org
Thu Jun 5 21:17:59 EDT 2008
#181: tac command missing in OSX
------------------------+---------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev at lists.osgeo.org
Type: defect | Status: new
Priority: minor | Milestone: 6.3.1
Component: default | Version: 6.3.0
Resolution: | Keywords: v.in.garmin, v.in.mapgen
------------------------+---------------------------------------------------
Comment (by 1gray):
Replying to [comment:10 glynn]:
> Replying to [comment:9 hamish]:
![...]
> > awk would be a great solution as this is fed directly into that. But
> > I have no idea how to write that.
> Replace:
> `... | tac | ...`
> with:
> `... | awk '{print NR,$0}' | sort -nr | sed 's/^[0-9]* //' | ...`
I see no reason to use Awk to number lines, since there's
[http://www.opengroup.org/onlinepubs/000095399/utilities/nl.html nl].
Neither I see a reason to use `sort`, since Awk has arrays:
{{{
awk_tac () {
awk '1 { last = NR; line[last] = $0; } END { for (i = last; i > 0;
i--) { print line[i]; } }'
}
if [ -n "$TAC" ] ; then
## do nothing
elif type tac ; then
TAC=tac
else
TAC=awk_tac
fi
... | $TAC | ...
}}}
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/181#comment:11>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list