From c20263e487a5f7509d715e14722c236f7232c8a8 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Sat, 14 Jul 2007 11:56:19 +0000 Subject: [PATCH] Add tac, a simple sed script to reverse stdin. This is from the GNU sed manual. --- usr.bin/tac/Makefile | 5 +++++ usr.bin/tac/tac.sed | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 usr.bin/tac/Makefile create mode 100644 usr.bin/tac/tac.sed diff --git a/usr.bin/tac/Makefile b/usr.bin/tac/Makefile new file mode 100644 index 0000000000..d299351514 --- /dev/null +++ b/usr.bin/tac/Makefile @@ -0,0 +1,5 @@ +# $DragonFly: src/usr.bin/tac/Attic/Makefile,v 1.1 2007/07/14 11:56:19 corecode Exp $ + +SCRIPTS= tac.sed + +.include diff --git a/usr.bin/tac/tac.sed b/usr.bin/tac/tac.sed new file mode 100644 index 0000000000..a81d47158b --- /dev/null +++ b/usr.bin/tac/tac.sed @@ -0,0 +1,22 @@ +#!/usr/bin/sed -nf + +# From the GNU sed manual, section 4.6. +# Copyright terms thereof: +# +# This document is released under the terms of the GNU Free Documentation +# License as published by the Free Software Foundation; either version 1.1, or +# (at your option) any later version. +# +# $DragonFly: src/usr.bin/tac/Attic/tac.sed,v 1.1 2007/07/14 11:56:19 corecode Exp $ + +# reverse all lines of input, i.e. first line became last, ... + +# from the second line, the buffer (which contains all previous lines) +# is *appended* to current line, so, the order will be reversed +1! G + +# on the last line we're done -- print everything +$ p + +# store everything on the buffer again +h -- 2.41.0