Last active
January 8, 2019 14:19
-
-
Save johngrib/9528e9b2306be8dcd4039312de5e8fb4 to your computer and use it in GitHub Desktop.
Print my examples of bash commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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