dashn

From the command line, run code for every line in some text.

dashn

From the command line, run code for every line in some text.

Roughly equivalent to ruby -ne '<code>' file1 … filen.

dashn '<code>' file1 … filen

cat a.txt | dashn '<code>'

<code> can reference any of the following:

line (String) - Current line of input. Trailing newline has been stripped.

num (Number) - Current line number of input. Starts at 1.

log (Function) - Alias for console.log.

error (Function) - Alias for console.error.

Given file a.txt containing

dog
cat
house

Running

dashn 'log(line.toUpperCase())' a.txt

prints

DOG
CAT
HOUSE

npm install -g dashn

MIT