Skip to content

Instantly share code, notes, and snippets.

@johngrib
Last active January 8, 2019 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johngrib/9528e9b2306be8dcd4039312de5e8fb4 to your computer and use it in GitHub Desktop.
Save johngrib/9528e9b2306be8dcd4039312de5e8fb4 to your computer and use it in GitHub Desktop.
Print my examples of bash commands
function exam {
wiki=`stat -f "%N" ~/johngrib.github.io/_wiki`
if [ "$1" = "-l" ]; then
egrep 'parent\s*:\s*command-line' $wiki/* -l 2> /dev/null \
| xargs grep 'summary' \
| sed "s,"$wiki"/,,; s,\.md:summary,," \
| column -ts':' | sort
return 0
fi
file=`egrep 'parent\s*:\s*command-line' $wiki/* -l 2> /dev/null \
| egrep "/$1.md$"`
if [ "$file" = "" ]; then
echo $wiki/$1.md : No such file.
return 0
fi
starts=`grep ':toc' $file -n | cut -d':' -f1`
cat $file | tail -n +$((starts+1)) \
| egrep -v "^\`\`\`" \
| sed -E 's/^\$/ /' \
| pygmentize -l sh \
| less -XRF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment