CLI tool for calling elixir functions
You must have Elixir installed.
Put the el
file in your $PATH and make sure that it is executable.
>> chmod +x el
>> cp el /usr/local/bin/el
Use the @
symbol to indicate where you would like the text from stdin to be passed in your code.
Call el with no flags and it will read all the lines from stdin and pass them to your code as a list of strings.
Example:
A more verbose verison of wc -l
cat some_file.txt | el "Enum.count(@)"
Drops the header row from the output...
df -h | el "Enum.drop(@, 1)"
Call el with the -l flag and it will read one line at a time and evaluate the code for the given line.
Example:
cat some_file.txt | el -l "String.upcase(@)"
Note that you can combine commands via pipes AND use Elixir's pipe operator.
df -h | el "Enum.drop(@, 1)" | el -l "String.upcase(@)" | el -l "String.split(@) |> Enum.at(3)"