My shell scripts #1 - Wikipedia search

I will publish my creations here, just in case someone finds them useful. My scripts are made for the ash shell, so they should work in most of the other shells. I run them on my OpenWrt router with 400MHz CPU and 32MB RAM with no problems :).

The first one I'm going to publish is a Wikipedia search script, requiring only "dig" and "sed" programs. Usage is fairly simple, just type:

$ ./ hello world

The script automatically replaces all spaces with underscores. And now the actual code:

if [ ! -n "$1" ]
  echo "What are you searching for?"
  echo "Usage:"
  echo "  $0 keyword"
  exit 1
q=`echo $* | sed 's/\ /\_/g'`
dig +short txt $ | sed 's/\"\ \"//'
exit 0

No comments:

Post a Comment