Skip to content

Instantly share code, notes, and snippets.

@Archenoth
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save Archenoth/6b66b1852fefd17c1b88 to your computer and use it in GitHub Desktop.

Select an option

Save Archenoth/6b66b1852fefd17c1b88 to your computer and use it in GitHub Desktop.
Ever felt an overwhelming urge to use words as command line arguments? Neither have I...but here's a script to find valid commands like "ls -chlorofluorocarbons" or "ls -Spank" anyway! Requires aspell.
#!/bin/bash
([ -z "$1" ] || [ -n "$2" ]) && cat <<EOF && exit 1
wordparam: Find words you can make with the short parameters of commands.
Author: Matthew (Archenoth) MacLean
Usage: "$0 <command>"
EOF
man $1 &>/dev/null || {
echo "Cannot find manpage for $1"
exit 1
}
echo "Generating for $1..."
aspell -d en dump master | aspell -l en expand | \
grep -e "$(echo "["$(for i in $(man $1 | grep -oe '\s-[a-Z]' | sort | uniq | cut -d'-' -f2); do echo -n $i; done)"]*")" -o | sort | uniq | \
less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment