Lessons · Terminal · the one that worked, written down
The one that worked, written down
A pipeline you will need again belongs in a small script with a sentence saying what question it answers.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
In three months the commands will still be readable and the intent will not.
How to think about it
One file, one comment, and it becomes something a colleague can find.
Worked example
printf '%s\n' '#!/bin/sh' '# Which endpoint is asked for most?' 'cut -d" " -f2 "$1" | sort | uniq -c | sort -rn' > top.shThe pipeline, and the question it answers.
chmod +x top.shMarked executable, so it can be run by name.
./top.sh access.logAnd it still works.
Your turn
Make the saved script runnable.
+x deploy.sh
Try it at a real prompt
The trap
Shell history is searchable until the day it is not, and it never says why you wrote the thing.
Practise the one that worked, written down on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.