Narthex

Modular dictionary generator
git clone git://mcdim.xyz/Narthex.git
Log | Files | Refs | README | LICENSE

nrev.sh (1443B)


      1 #!/bin/sh
      2 
      3 #
      4 #      nrev - Narthex reverser
      5 #  by Michael Constantine Dimopoulos https://mcdim.xyz <mk@mcdim.xyz>
      6 #
      7 #  nrev iterates over stdin or a file and, after reprinting the
      8 #  dctionary, it will reprint it again but with each line reversed.
      9 #
     10 ###################
     11 #
     12 #  This program is free software: you can redistribute it and/or modify
     13 #  it under the terms of the GNU General Public License as published by
     14 #  the Free Software Foundation, either version 3 of the License, or
     15 #  (at your option) any later version.
     16 #
     17 #  This program is distributed in the hope that it will be useful,
     18 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 #  GNU General Public License for more details.
     21 #
     22 #  You should have received a copy of the GNU General Public License
     23 #  along with this program.  If not, see <https://www.gnu.org/licenses/>.
     24 
     25 
     26 version="1.2.1"
     27 
     28 if   [ "$1" = "-v" ]; then echo v$version; exit;
     29 elif [ "$1" = "-h" ];
     30 then
     31 	printf  "nrev - Narthex reverser ${version}  \n";
     32 	printf	"By Michael Constantine Dimopoulos <mk@mcdim.xyz>\n\n";
     33 
     34 	printf	'%s\n' "-h  print this panel & exit";
     35 	printf	'%s\n\n' "-v  print current version & exit";
     36 
     37 	printf	"Usage:	nrev [FILENAME]\n";
     38 	printf  "	cat [FILENAME] | nrev\n";
     39 	exit;
     40 fi
     41 
     42 filename=$(mktemp);
     43 
     44 while read line
     45 do
     46 	echo "$line" >> $filename;
     47 done < "${1:-/dev/stdin}"
     48 
     49 cat $filename;
     50 cat $filename | rev;