3 ms·
On a tangent, I'd be interested in how you format heavily piped bash code for documentation. Can comments be intersparsed there?
by m_mueller 12y ago
On a tangent, I'd be interested in how you format heavily piped bash code for documentation. Can comments be intersparsed there?
- mappu 12y agoFunctions, mostly - the big `awk` command in the example goes into something like # @param $1 whatever chess_extract_scores() { awk blah blah blah } and then your whole pipeline simplifies to cat foo | grep bar | chess_extract_scores which is pretty readable. You can even do most of this in a live bash session with ^X ^E.
- plaes 12y agoYou can actually do without cat: grep bar foo | chess_extract_scores http://en.wikipedia.org/wiki/Cat_%28Unix%29#Useless_use_of_cat http://en.wikipedia.org/wiki/Cat_%28Unix%29#Useless_use_of_c...
- nkuttler 12y agoSure you can, but premature optimization is also a real thing http://en.wikipedia.org/wiki/Program_optimization#When_to_optimize http://en.wikipedia.org/wiki/Program_optimization#When_to_op...
- dsr_ 12y agobash has functions; functions are just like commands. Write your comments in the functions, and your final line will be the pipeline of awesomeness: generate_data () { # make it rain } process () { # chunky } gather () { # puree } generate_data | process | gather