eddie
Changes To UnixCommands
Not logged in
Public Repositories
mwm's Repositories

Initial version of "UnixCommands"

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#How to implement various Unix commands with eddie.

## Introduction

This is just a list of unix commands (or things that feel like they should be Unix commands) along with a partial implementation of them using eddie.

## The Unix Bestiary

<dl>
<dt>*uniq* - remove duplicated lines:</dt>
<dd>`eddie -lL nub` will remove all dupliciates. `eddie -Ll "map head . group"` only works on presorted files, but works in *O*(n) time.</dd>

<dt>*head* - print the first few lines of a file:</dt>
<dd>`eddie -lL "take 10"`</dd>

<dt>*tail* - print the last 10 lines of a file:</dt>
<dd>`eddie -lLm Data.List.Utils "drop =<< subtract 10 . length"`</dd>

<dt>*wc* - count words (or lines, or characters) in a file:</dt>
<dd>count characters with `eddie show.length`<br />
count words with `eddie show.length.words`<br />
count lines with `eddie show.length.lines`</dd>

<dt>*fgrep* - select lines containing a substring:</dt>
<dd>`eddie -lL 'filter (isInfixOf "substring")'`</dd>

<dt>*grep* - select lines matching a regular experssion:</dt>
<dd>`eddie -lLm Text.Regex.TDFA '(filter (=~ "r.e."))'`</dd>

<dt>*sort* - sort the lines in a file:</dt>
<dd>`eddie -lL sort`</dd>

### The Alternative Bestiary

A collection of commands that do unix-like file processing but don't correspond to a generaly available command (borrowing heavily from http://www.haskell.org/haskellwiki/Simple_unix_tools.)

<dl>
<dt>Repeat a file endlessly.</dt>
<dd>`eddie cycle`<dd>

<dt>Print a file double spaces</dt>
<dd>`eddie -lL 'intersperse ""'`</dd>

<dt>Strip blank lines</dt>
<dd>`eddie -lL  'filter (not . null)'`</dd>

<dt>Map a file to upper case</dt>
<dd>`eddie "map toUpper"`</dd>

<dt>Strip whitespace from lines in a variety of ways</dt>
<dd>From the start of each line: `eddie -l 'dropWhile isSpace'`<br />
From the end of each line: `eddie -l 'reverse . dropWhile isSpace . reverse'`<br />
From both ends of a line: `eddie -l 'let f = reverse . dropWhile isSpace in f . f'`</dd>

<dt>Indent all the lines in a file</dt>
<dd>`eddie -l '("     " ++)'`</dd>