Synsh Blog RSS

Synsh: A Shell Pipeline Synthesizer

Synsh (synsh.dev) is a tool that automatically creates shell pipelines from examples. Given an example of the input to the pipeline and the expected output, Synsh attempts to find a pipeline that transforms the input into the output.

For example, given the following input:

Tina, Bassist, Coronado
David, Singer, Dumbarton
Chris, Drummer, Fort Campbell
Jerry, Guitarist, Milwaukee

and the following example output:

Bassist: Tina
Drummer: Chris
Guitarist: Jerry
Singer: David

Synsh outputs the following pipeline, with comments explaining each command:

# 1. Select fields 1 and 2 in order 2 and 1, separated by ", ".
# 2. Sort lines by alphanumeric value, by field 1.
# 3. Replace "," by ":".
awk -F ', ' 'BEGIN { OFS = ", " } { print $2, $1 }' | \
  sort -k 1,1 | \
  tr , ':'

Usage

To create a shell pipeline with Synsh, enter the pipeline’s input in the “Input” field and enter the desired output in the “Output” field. Synsh automatically searches as you type; there is no need to explicitly trigger a search.

About

Synsh was written by Pat Rondon. All feedback and questions are welcome at pat.rondon@gmail.com.

Thanks to Evan Rose for feedback on an earlier version of Synsh.