From 23f0e1561767dd8a396188e317bae5920d171ea8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sun, 16 Aug 2015 16:38:25 +0200 Subject: Initial import of my nikola website --- stories/projects/el.rst | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 stories/projects/el.rst (limited to 'stories/projects/el.rst') diff --git a/stories/projects/el.rst b/stories/projects/el.rst new file mode 100644 index 0000000..8633181 --- /dev/null +++ b/stories/projects/el.rst @@ -0,0 +1,72 @@ +.. link: +.. description: is a unix tool aiding the Telefonbuch project for export and search queries. +.. tags: project +.. date: 2015/02/01 19:10:08 +.. title: el +.. subtitle: extract lines from text files +.. slug: ../arts/software/el/index +.. prio: 100 + +.. contents:: + :depth: 1 + :class: ezjail-toc + +---- + +Overview +======== + +*el* (from extract lines) is a unix tool to efficiently extract lines from a text file using a dynamic line end index. Its command line syntax is tuned to work with other posix tools – especially grep – to easily operate on poor man's databases where each of the database's columns is in a separate newline separated file. + +Since *el* mmaps the whole file, it does not work on streams. + +---- + +Build instructions +================== + +Get the source from my git repository ``git clone git://erdgeist.org/el`` and type ``make`` in the directory ``el``. *el* has no further dependencies and can just be copied to ``/usr/local/bin`` or wherever your binaries reside. + +---- + +Invocation +========== + +In its simplest form just run:: + + echo 1 2 3 4 5 6 7 8 9 10 | el file.txt + +to extract lines 1 to 10 from the file ``file.txt`` and print them to stdout. *el* also accepts white space separated line numbers with the ``-i`` parameter and can default to hexadecimal numbers with the ``-x`` switch:: + + el -i "10 11 12 13" -x file1.txt file2.txt + +extracts line 16 to 19 from the files ``file.txt`` and ``file2.txt``, each line separated by the tab character. If your line numbers start at ``0``, *el* will add 1, if it is run with the ``-0`` switch. + +The reason reading line numbers from stdin and not from command line by default becomes apparent, when you use the combining features of *el*, as it can parse and generate output as the ``grep`` posix tool does. + +If you use the ``-n`` switch, each extracted line is prefixed by it's line number and a colon, just as ``grep`` does. If you use the ``-g`` switch, *el* will also **expect** the line numbers on stdin to be terminated by a colon followed by garbage until next newline. So you can feed results from ``grep -n`` directly to it. With the ``-G`` option, not only will *el* parse the line numbers from ``grep``'s output, but also append the extracted lines from each file to the input line. In order to chain several ``grep`` and *el* commands, best combine the ``-Gn`` switches as in this example:: + + grep -n Manager positions.txt | el -Gn firstname.txt lastname.txt | grep Jon | el -Gn salary.txt + +This will produce, an output like this:: + + 17:Manager\tJon\tMiller\t$1200 + 23:Manager\tJon\tDoe\t$1600 + +given that all the text files contain corresponding rows of information about the staff. + +---- + +Author +====== + +*el* was written by `Dirk Engling `_, who likes to hear from happy customers. + +---- + +License +======= + +*el* is considered `beer ware `_. + + -- cgit v1.2.3