faithless1
asked on
Help with fixing a script
Hi,
Can someone please provide a working version of this script? I can't seem to figure out how to make this work. Also, if there is a better way to do this with another language that will return the same output, that would be great as well.
The main function of the script is to take a file as input (keyword.txt) with keywords on each line (space delimited) overlap it with Unix built in dictionary and output only keywords that are found in the dictionary. (At least that's my understanding of it)
Thanks
main.sh
#!/bin/sh
cat $1 | tr A-Z a-z| grep keyword | cat -v|\
sed -e 's/\([a-z]\+\.\)\+\(com\|o rg\|net\)[ ^ ]*//g' -e 's/[^a-z ]/ /g' -e 's/[ ]\+/ /g' |\
awk '{j=-1;for (i=1;i<=NF;i++)if(length($ i) < 3 || match($i,"^with$|^from$|^t xt$|^and$| ^for$|^the $|^com$") ) $i="";print }'|\
sed -e 's/^[ ]\+//g'|\
awk '(NF>2) {j=-1;for (i=1;i<NF;i++) if($i=="keyword"){ j=i;i=1000;};if(j>0) {if(j==1) j++;if(j==NF) j--;k=j-1;l=j+1; print $k "\t" $j "\t" $l;}}'|\
sort -u |sh ll.sh |sort -k +3|sh llc.sh |sort
llc.sh
#!/bin/sh
olda=""
while read c b a
do
if [ "$a" != "$olda" ]
then
grep -q "^$a" /usr/share/dict/words >/dell/null
valid=$?
fi
olda=$a
[ $valid -eq 0 ] && echo -e "$c\t$b\t$a"
done
ll.sh
#!/bin/sh
olda=""
while read a b c
do
if [ "$a" != "$olda" ]
then
grep -q "^$a" /usr/share/dict/words >/dell/null
valid=$?
fi
olda=$a
[ $valid -eq 0 ] && echo -e "$a\t$b\t$c"
done
Can someone please provide a working version of this script? I can't seem to figure out how to make this work. Also, if there is a better way to do this with another language that will return the same output, that would be great as well.
The main function of the script is to take a file as input (keyword.txt) with keywords on each line (space delimited) overlap it with Unix built in dictionary and output only keywords that are found in the dictionary. (At least that's my understanding of it)
Thanks
main.sh
#!/bin/sh
cat $1 | tr A-Z a-z| grep keyword | cat -v|\
sed -e 's/\([a-z]\+\.\)\+\(com\|o
awk '{j=-1;for (i=1;i<=NF;i++)if(length($
sed -e 's/^[ ]\+//g'|\
awk '(NF>2) {j=-1;for (i=1;i<NF;i++) if($i=="keyword"){ j=i;i=1000;};if(j>0) {if(j==1) j++;if(j==NF) j--;k=j-1;l=j+1; print $k "\t" $j "\t" $l;}}'|\
sort -u |sh ll.sh |sort -k +3|sh llc.sh |sort
llc.sh
#!/bin/sh
olda=""
while read c b a
do
if [ "$a" != "$olda" ]
then
grep -q "^$a" /usr/share/dict/words >/dell/null
valid=$?
fi
olda=$a
[ $valid -eq 0 ] && echo -e "$c\t$b\t$a"
done
ll.sh
#!/bin/sh
olda=""
while read a b c
do
if [ "$a" != "$olda" ]
then
grep -q "^$a" /usr/share/dict/words >/dell/null
valid=$?
fi
olda=$a
[ $valid -eq 0 ] && echo -e "$a\t$b\t$c"
done
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER