task_boiler
This is an old revision of the document!
Table of Contents
task boiler
Place to cook the tasks. Once they are boiled enough, move them to a separate plate.
Start the first heading with “=====”
apply unix commands to all but the first line
Situation
Let's say we want to sort a series of numbers in descending order but keep the header at the top. For example, given
$ echo -e "value\n8\n2\n6\n3" value 8 2 6 3
we want to output
value 2 3 6 8
We can't directly use 'sort' since it will sort the header as well.
$ echo -e "value\n8\n2\n6\n3" | sort 2 3 6 8 value
simple solution
Create a script called 'body' with the following contents and place it somewhere in your PATH.
#!/usr/bin/env bash # # body: apply expression to all but the first line. # Use multiple times in case the header spans more than one line. # # Example usage: # $ echo -e "value\n8\n2\n6\n3" | body sort # IFS= read -r header printf '%s\n' "$header" "$@"
Give it exec
task_boiler.1660252785.txt.gz · Last modified: 2022/08/11 21:19 by raju