Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A series of challenges for people who love command-line one-liners.
branch: master

This branch is 8 commits behind jpalardy:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
001_count
002_last_paragraph
003_intersection
004_sum
005_no_blank_lines
006_merge_2_files
007_word_count
008_join_with_commas
009_subtraction
README.md

README.md

About

Blog post: Command-line One-liner Challenges

Watch this project, I'll add more challenges over time.

How it works

There are 4 files to know about:

  • input.txt -- The input file.
  • compare.sh -- What you need to run. Some implementation is missing.
  • actual.txt -- The output of the transformed input.txt. Created by running compare.sh.
  • expected.txt -- What input.txt needs to be transformed into.

Each directory contains two subdirectories: problem and solution. The only difference between problem and solution directories is the content of compare.sh file.

In the problem directory, you need to implement the convert function inside compare.sh. This is always the same, a passthrough function:

convert() {
  cat "$@"
}

You are aiming for a one-liner. It should be as functional as possible: no variables, temporary files, or side-effects.

Invoke compare.sh

./compare.sh

There is still work to do if you get:

Files actual.txt and expected.txt differ

If you are debugging, you can change the diff command to whatever suits you:

DIFF=vimdiff ./compare.sh

Or:

DIFF="diff -u" ./compare.sh

Something went wrong with that request. Please try again.