SHARE
TWEET

Untitled

a guest Jun 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. #----------------------------------------------\
  4. #Christopher Nulph | Assignment 2C | Oct 6 2010|
  5. #----------------------------------------------|
  6. #Builds a 6x6 table where the first 6 chars of |
  7. #the strings entered are the labels and the    |
  8. #script checks words that begin with i and end |
  9. #with j.                                       |
  10. #**********************************************|
  11. #Note:  Bash is not freezing when executed, it |
  12. #       simply takes some time to manuver in   |
  13. #       the wordlist.                          |
  14. #                              |
  15. #      granite.sru.edu/~crn5346/table.html     |
  16. #----------------------------------------------/
  17.  
  18. #Redirect all output of this script to table.html
  19. exec 1>/homes/crn5346/public_html/table.html
  20.  
  21. name="$1$2"
  22. tablelabels=`echo $name|cut -c 1-6|more`
  23.  
  24. echo "<table border='1'><TR><td>&nbsp;</td>"
  25. i=1
  26. while [ $i -le 6 ] #Table Header Row
  27. do
  28.     echo "<td>"`echo $name|cut -c $i|more`"</td>"
  29.     i=$((i+1))
  30. done
  31.  
  32. echo "</tr>"
  33.  
  34. j=1
  35. i=1
  36. dict=/usr/share/dict/words
  37.  
  38. while [ $j -le 6 ] #Rows with letter
  39. do
  40.     echo "<tr><td>"`echo $name|cut -c $j|more`"</td>"
  41.  
  42.     while [ $i -le 6 ] #Content of each row from words file.
  43.     do
  44.         col=`echo $name|cut -c $i|more` #ith letter
  45.         row=`echo $name|cut -c $j|more` #jth letter
  46.         echo "<td>"`grep -c -e ^$col.*$row$ $dict` "</td>"
  47.  
  48.         i=$((i+1))
  49.     done
  50.    
  51.     echo "</tr>"
  52.     i=1
  53.     j=$((j+1))
  54. done
  55.  
  56. echo "</table>"
RAW Paste Data
Want to get better at Bash?
Learn to code Bash in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top