# Mirror a website with wget to a depth of 3 hyperlinks wget -r -l2 http://www.geocities.com/matth3wbishop/ # A pipe-line to take a plain text file, format it as a single list # of unique, alphabetically sorted words, and to translate each of those # words using a unix/ linux / debian program called i2e.sh # The -e switch of i2e specifies that only exact matches should # be used. Otherwise the word 'a' will return hundreds of matches. for w in $(cat tutor-phrase-help.txt | tr '[A-Z]' '[a-z]' | sed 's/[^a-z]/ /g' | tr ' ' '\n' | sed '/^ *$/d' | sort | uniq); do i2e.sh -e $w; done | sed "/^ *$/d" | more # A pipe to do something once for each line of a particular file # Alternatively you could use xargs, but I have difficuly getting # xargs to do what I want it to do. for w in $(cat temp2); do i2e.sh -e $w; done | more # A command line to emulate the 'for' loop in programming languages for i in $(seq 7); do echo hello; done # Summarize disk usage for the current directory. That is, do not # display disk usage statistics for each sub-directory. du -s . # The command line below takes an example sentence and turns it into # a word-for-word translation in spanish using the i2e program # It prints the original phrase and its translation of the following # line. Words which are not in the dictionary are rendered as # [???] s="hello how are you"; echo $s; for v in $(echo $s); do i2e.sh -e $v | sed "/^ *$/d" | head -1 | sed "s/not found in.*/[???]/gi" | sed "s/^[^:]*://" | tr '\n' ' '; done; echo "" #-- This command is similar to the above but does the translation process #-- for each line in a named file, in this case the file is called #-- tutor-phrase-help.txt. for line in $(cat tutor-phrase-help.txt | tr ' ' '#'); do s=$(echo $line | tr '#' ' '); echo $s; for v in $(echo $s); do i2e.sh -e $v | sed "/^ *$/d" | head -1 | sed "s/not found in.*/[???]/gi" | sed "s/^[^:]*://" | tr '\n' ' '; done; echo ""; done | more #-- Slightly improved display layout but becoming quite slow for line in $(cat tutor-phrase-help.txt | sed "/^[^a-zA-Z]*$/d" | tr ' ' '#'); do s=$(echo $line | tr '#' ' '); echo $s; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do printf '('; i2e.sh -e $v | sed "/^ *$/d" | sed "s/not found in.*/[???]/gi" | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' | sed "s/^ *//g" | sed "s/ *$//g" | tr '\n' '|'; printf ') '; done; echo ""; echo "+++++++++"; done | sed 's/[|][)]/)/g' | more #-- A slightly improved version of the same. This is beginning to become #-- slow for the shell to process. This version displays only one #-- equivalent word for each english word. for line in $(cat tutor-phrase-help.txt | sed "/^[^a-zA-Z]*$/d" | tr ' ' '#'); do s=$(echo $line | tr '#' ' '); echo $s; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do i2e.sh -e $v | sed "/^ *$/d" | head -1 | sed "s/not found in.*/[???]/gi" | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' | tr '\n' ' '; done; echo ""; echo "+++++++++"; done | more #-- This version of the translator displays every alternative meaning #-- for the target english word and encloses the sets of meanings in #-- triangle brackets. The display format is really not very clear for line in $(cat tutor-phrase-help.txt | sed "/^[^a-zA-Z]*$/d" | tr ' ' '#'); do s=$(echo $line | tr '#' ' '); echo $s; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do printf '['; i2e.sh -e $v | sed "/^ *$/d" | sed "s/not found in.*/[???]/gi" | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' | tr '\n' ','; printf '] '; done; echo ""; echo "+++++++++"; done | more #-- This is a much better layout format, displaying one alternative for #-- a give english word, assuming that the alternative is available, #-- and displaying the alternative on a different line. for line in $(cat tutor-phrase-help.txt | sed "/^[^a-zA-Z]*$/d" | tr ' ' '#'); do s=$(echo $line | tr '#' ' '); echo $s; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do i2e.sh -e $v | sed "/^ *$/d" | head -1 | sed "s/not found in.*/[???]/gi" | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' | sed "s/^ *//g" | sed "s/ *$//g" | tr '\n' ' '; done; echo ""; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do i2e.sh -e $v | sed "/^ *$/d" | head -2 | tail -1 | sed "s/not found in.*/[???]/gi" | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' | sed "s/^ *//g" | sed "s/ *$//g" | tr '\n' ' '; done; echo ""; echo "=============================="; done | more #-- A pipe to set up an alias (short command) to print out the current #-- date and time in Barcelona, Spain alias thetime='lynx --dump www.timeanddate.com/worldclock/city.html?n=31 | grep -A4 "Barcelona, Spain"' #-- Sets up an alias to print a description of programs (normally executable) #-- which a contained in the various bin directories of the linux system #-- This gives you a very approximate idea of what commands are available #-- on the current computer system. (use the whatis -r switch instead) alias desc='for i in $(locate /bin/); do whatis $(basename $i); done | grep -v "nothing appropriate"' #-- A better version is something like whatis -r '.*' #-- Here is a script version of the translator command line above. #-- Ella_Associates:~/mjb# cat tradoos.sh #-- A script to provide what is called a "gist" translation of a text file #-- It is called tradoos because apparently there is some translating #-- software called 'trados' for line in $(cat $1 | sed "/^[^a-zA-Z]*$/d" | tr ' ' '#') do s=$(echo $line | tr '#' ' ') echo $s #-- process each word in the line, reducing to lower case #-- and removing puntuation for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g") do i2e.sh -e $v | sed "/^ *$/d" \ | head -1 | sed "s/not found in.*/[???]/gi" \ | sed "s/^[^:]*://" \ | sed 's/A (abrev\. de amperio)/uno/i' \ | tr '\n' ' ' done echo "" echo "+++++++++" done #-- Another idea for the translator would be to produce #-- html layout with select boxes containing alternate #-- translations of a particular word #-- Also, by removing the s, er, ed, ing suffixes is would #-- be possible to match more words. #-- This is quite slow, approximately 3 lines per second. It #-- may be possible to speed up the script using the sed -e switch #-- instead of using pipes. Ella_Associates:~/mjb# cat tradoos2.sh for line in $(cat tutor-phrase-help.txt | sed "/^[^a-zA-Z]*$/d" | tr ' ' '#'); do s=$(echo $line | tr '#' ' '); echo $s; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do i2e.sh -e $v | sed "/^ *$/d" \ | head -1 | sed "s/not found in.*/[???]/gi" \ | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' \ | sed "s/^ *//g" | sed "s/ *$//g" \ | tr '\n' '|'; done; echo ""; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do i2e.sh -e $v | sed "/^ *$/d" \ | head -2 | tail -1 | sed "s/not found in.*/[???]/gi" \ | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' \ | sed "s/^ *//g" | sed "s/ *$//g" \ | tr '\n' '|'; done; echo ""; for v in $(echo $s | tr '[A-Z]' '[a-z]' | sed "s/[^a-z]/ /g"); do i2e.sh -e $v | sed "/^ *$/d" | head -3 | tail -1 \ | sed "s/not found in.*/[???]/gi" \ | sed "s/^[^:]*://" | sed 's/A (abrev\. de amperio)/uno/i' \ | sed "s/^ *//g" | sed "s/ *$//g" \ | tr '\n' '|' ; done; echo ""; echo "=============================="; done #-- Take a text file containing a mailing address list and reformat it #-- as one email address per line, only Hotmail address and with no #-- 'nick-names' in front of the email addresses. D:\mjb>cat grapevine-mail.txt | tr "," "\n" | sed -e "s/^[^<]* *$//gi " | grep "hotmail.com" > grapehot.txt #-- to format the sedfaq.html for htmldoc to turn to pdf cat sedfaq.html | \ sed "/^CONTENTS:/,/^
/d" | \ sed "/^[0-9]\. /s/.*/

&<\/h2>/g" | \ sed "/^[0-9]\.[0-9]\. /s/.*/

&<\/h3>/g" | \ sed "s/ \{2\}/\ \ /g" | \ sed "/^ */!s/^/
/g" | \ sed "1,/\(\ \)*//g" | less DIDO# cat sedfaq.html | \ sed "/^CONTENTS:/,/^
/d" | \ sed "/^[0-9]\. /s/.*/

&<\/h2>/g" | \ sed "/^[0-9]\.[0-9]\. /s/.*/

&<\/h3>/g" | \ sed "s/ \{2\}/\ \ /g" | \ sed "/^ */!s/^/
/g" | \ sed "1,/\(\ \)*//g" | \ sed "/

1\. /s/^/

The Seq FAQ<\/h1>/g" > sedfaq-new.html #-- A pipe to add extra 'unique' lines to a file DIDO# l=$(cat librarymenu.old.txt | sed -n "/All\-Time/p"); for i in $(seq 300); do echo $l | sed "s/^/$i/g" ; done >> Librarymenu.txt