summaryrefslogtreecommitdiff
path: root/stories/projects/el.rst
diff options
context:
space:
mode:
authorerdgeist <erdgeist@bauklotz.local>2015-08-16 16:38:25 +0200
committererdgeist <erdgeist@bauklotz.local>2015-08-16 16:38:25 +0200
commit23f0e1561767dd8a396188e317bae5920d171ea8 (patch)
treea67f44e39ad8a45e42d60634488a65c37f3ad432 /stories/projects/el.rst
Initial import of my nikola website
Diffstat (limited to 'stories/projects/el.rst')
-rw-r--r--stories/projects/el.rst72
1 files changed, 72 insertions, 0 deletions
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 @@
1.. link:
2.. description: is a unix tool aiding the Telefonbuch project for export and search queries.
3.. tags: project
4.. date: 2015/02/01 19:10:08
5.. title: el
6.. subtitle: extract lines from text files
7.. slug: ../arts/software/el/index
8.. prio: 100
9
10.. contents::
11 :depth: 1
12 :class: ezjail-toc
13
14----
15
16Overview
17========
18
19*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.
20
21Since *el* mmaps the whole file, it does not work on streams.
22
23----
24
25Build instructions
26==================
27
28Get 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.
29
30----
31
32Invocation
33==========
34
35In its simplest form just run::
36
37 echo 1 2 3 4 5 6 7 8 9 10 | el file.txt
38
39to 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::
40
41 el -i "10 11 12 13" -x file1.txt file2.txt
42
43extracts 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.
44
45The 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.
46
47If 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::
48
49 grep -n Manager positions.txt | el -Gn firstname.txt lastname.txt | grep Jon | el -Gn salary.txt
50
51This will produce, an output like this::
52
53 17:Manager\tJon\tMiller\t$1200
54 23:Manager\tJon\tDoe\t$1600
55
56given that all the text files contain corresponding rows of information about the staff.
57
58----
59
60Author
61======
62
63*el* was written by `Dirk Engling <mailto:erdgeist@erdgeist.org>`_, who likes to hear from happy customers.
64
65----
66
67License
68=======
69
70*el* is considered `beer ware </beerware.html>`_.
71
72