This is a trimmed and scaled down portion of the script I am working on.
I am trying to figure out how to get it to post properly on my website using kompoZer so anyone could look at the whole of it to help me, if they are willing. But until then.
It is a learning experiance for me and hopefully will be useful for me when its done. I know it needs a huge amount of cleaning (if not just thrown out!).
I started making a simple front end (if I am using the term correctly). Thats when I realized the comparison part of the script (lines 30-48) is not yet easily configurable for me.
I think I will be able, using the basic tools and constructs in a script, to change the number and content of the various lists that are being used and to feed them into the script. But when it comes to the comparison part I don't know how to proceed.
I am guessing that some form of nested loop would be best,(but of course, I have yet to be correct about anthing)
I would like to be able to change the value and the shear number of the different categories that are being parsed for. I may only want to parse for the three categories that are shown here
but I may want to parse for twenty different categories.
Please offer up the good ways to make the comparison part of this configurable. I would like to stick with bash and the basics because that is after all what I am trying to learn at this time.
Please start with just the ideas don't post a finished script. Obviously I haven't been able to figure it out on my own but if you say it will definatly
work using "name an idea" I will bang my head against man and google some more on that specific idea.
Thanks for any help, I am going to ask for general cleanup help with it when I can get it to post proper on my website.
Code:
3 #!/bin/bash
4 exec 2>/home/teabear/zmyworkspace/script1.log
5 set -x
6
7 IFS="
8 "
9 kdialog -passivepopup "started" 4
10
11 elist=/home/teabear/bashwork/indvlist/electriclist
12 folist=/home/teabear/bashwork/indvlist/foodlist
13 plist=/home/teabear/bashwork/indvlist/puterlist
14
15 sort -m -o /home/teabear/bashwork/mfilelist/mfile $elist $plist $folist
16 cp /home/teabear/bashwork/mfilelist/mfile /home/teabear/bashwork/troubleshooting/parsingfiles/mfile_$i
16
17 for i in `ls /home/teabear/bashwork/dragto`; do
18 grep -awio -f /home/teabear/bashwork/mfilelist/mfile /home/teabear/bashwork/dragto/$i | cat > /home/teabear/bashwork/extractedlist
19
20 phit=`grep -ioc -f /home/teabear/bashwork/indvlist/puterlist /home/teabear/bashwork/extractedlist`
21 ehit=`grep -ioc -f /home/teabear/bashwork/indvlist/electriclist /home/teabear/bashwork/extractedlist`
22 fohit=`grep -ioc -f /home/teabear/bashwork/indvlist/foodlist /home/teabear/bashwork/extractedlist`
23
24 fofold=/home/teabear/bashwork/destinationfolders/food
25 pfold=/home/teabear/bashwork/destinationfolders/puter
26 efold=/home/teabear/bashwork/destinationfolders/electric
27
28 acon=/home/teabear/bashwork/dragto/$i
29
30 if [ "$ehit" -gt "$fohit" ] && [ "$ehit" -gt "$phit" ]
31 then kdialog -passivepopup "$i file will be moved to Electrical folder" 2
32 cp /home/teabear/bashwork/extractedlist /home/teabear/bashwork/troubleshooting/parsingfiles/extractedlist_$i
33 mv $acon $efold
35
36 elif [ "$fohit" -gt "$ehit" ] && [ "$fohit" -gt "$phit" ]
37 then kdialog -passivepopup "$i file will be moved to Culinary folder" 2
38 cp /home/teabear/bashwork/extractedlist /home/teabear/bashwork/troubleshooting/parsingfiles/extractedlist_$i
39 mv $acon $fofold
41
42 elif [ "$phit" -gt "$fohit" ] && [ "$phit" -gt "$ehit" ]
43 then kdialog -passivepopup "$i file will be moved to Puter folder" 2
44 cp /home/teabear/bashwork/extractedlist /home/teabear/bashwork/troubleshooting/parsingfiles/extractedlist_$i
45 mv $acon $pfold
47
48 fi
49 done
50
51 kdialog -msgbox "end"
52
53