3 ms·
This should work: #!/bin/bash cmd="$(cut -d ' ' -f 1 <<< "$@" )"; args="$(cut -d ' ' -f 2- <<< "$@" )"; url="http://explainshell.com/explain/$c
by jbackus 13y ago
This should work:
#!/bin/bash
cmd="$(cut -d ' ' -f 1 <<< "$@" )";
args="$(cut -d ' ' -f 2- <<< "$@" )";
url="http://explainshell.com/explain/$cmd?args=$args"
explanation="$(curl -s $url | grep '<pre' | sed -E 's/<\/?[a-z]+(\ [a-z]+=\"[a-z0-9]+\")*>//g' | sed -E 's/^\ +//g')"
echo "$explanation"
Example:
~$ tar xzvf archive.tar.gz
~$ explain !!
explain tar xzvf archive.tar.gz
The GNU version of the tar archiving utility
-x, --extract, --get
-z, --gzip, --gunzip --ungzip
-v, --verbose
-f, --file ARCHIVE
Save in /usr/local/bin. Gist: https://gist.github.com/backus/6387485 https://gist.github.com/backus/6387485
- Toenex 13y agoBeautiful. Thank you.