Here's a puzzle for bash experts. Create a file named
- It must be 3 lines long.
- All lines except the first must consist solely of the string
- If you run
bash puzzle.3, you should receive the response:
puzzle.3: line 3: futz: command not found
puzzle.3 file should behave exactly like this:
$ wc -l puzzle.3 ; tail -n +2 puzzle.3 3 puzzle.3 futz futz $ bash puzzle.3 puzzle.3: line 3: futz: command not found $
Now instead of 3, try 4 and 5. The challenge: how short can you make that first line? My results:
$ for i in 3 4 5; do echo puzzle.$i: $(head -1 puzzle.$i | wc -c); done puzzle.3: 4 puzzle.4: 4 puzzle.5: 10 $
I don't think it's possible to do better. Prove me wrong! Remember that
wc -c includes the newline, so there are 3, 3, and 9 actual characters on the first lines of each of those files respectively.
Click to cheat and view my answers! But try on your own first.
$ cat puzzle.3 : \ futz futz $ cat puzzle.4 <<\ futz futz futz $ cat puzzle.5 <<futz<<\ futz futz futz futz $
Update: Someone on reddit beat my
puzzle.3 by one, with
Note: I am operating under the assumption that you don't have anything named futz in your PATH.