This is a discussion on OT : Match number-string script ? within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Bryan Bibb wrote: .... contumacious ... Geez! One that even _I_ had to look up! And in so doing, ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| On Tue, 10 Aug 2004 07:47:47 -0500, +Alan Hicks+ schrieb : > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > In alt.os.linux.slackware, Kleeb dared to utter, >> Thanks Alan. You're right in that scripting is very new to me, but it's >> something I've wanted to be able to do, at least in a basic way, for >> some time. > > Let me give you the same advice Faux_Pseudo gave me when I was starting > out. Use the console for everything you possibly can, and for every task > you find yourself having to do, at least attempt to write a script to do > it for you. Soon enough you'll be picking things up, learning what > works, what doesn't. Well, I've actually achieved my goal, by using a couple of simple commands. I've dressed it up to produce an output that I can read more easily. Apologies to those of you who gave me more elaborate (but no less useful, to the contrary actually) tips. You didn't waste your time, but I must learn to walk before I can run. As Alan says, using the console, is at least in my case, the course of action which has yielded the best results. Most of the replies to this thread have been saved for future reference. Thanks to (nearly) all posters one last time. Without further waffling, for those who are morbidly curious, here's what I did : I have three files in all. One is called 'lottery', and consists of 19 lines of tab-seperated two-digit numbers. This never changes. Another is called 'winhope', and consists of the six winning two-digit numbers, each on a seperate line. I just update these numbers on each draw. The last file is the 'script' called 'lot' which puts them all on the screen for me. Here is the 'lot' script : #!/bin/bash date echo "" echo "Here is the table of all the syndicate numbers ..." echo "" cat -n /home/foo/bar/lottery echo "" echo "Winning numbers :" echo "" cat /home/foo/bar/winhope echo "" echo "Matching lines :" echo "" grep -nof /home/foo/bar/winhope /home/foo/bar/lottery Yeah, I know it's crap looking, but it works. To check a draw, I do the following : $ vim bar/winhope (enter six numbers, save and quit). $ lot Done. The output looks like this : Wed Aug 11 01:02:30 BST 2004 Here is the table of all the syndicate numbers ... 1 xx xx xx xx xx xx 2 xx xx xx xx xx xx 3 xx xx xx xx xx xx ... ... ... Winning numbers : xx xx xx xx xx xx Matching lines : 1:xx xx xx xx xx xx 2:xx 3:xx 4:xx 6:xx 8:xx 9:xx 10:xx 11:xx 12:xx 16:xx xx 19:xx Ugly maybe, but functional. There's not a lot of difference to me actually using the commands in the script on their own, except that it takes longer to do. The script just automates it slightly for me. I did it this way so I can also just copy and paste the whole output into an email, and everybody can see what's going on, hopefully. Entering in the six numbers, and typing 'lot' takes me about 15 secs, and it's all laid out a lot easier for me to see, than if I had a pink lotto slip, and had to pour over the syndicate list to find matching numbers. That was the whole point of this 'exercise' for me. I've also found out a lot more about grep, sort and uniq, and cat, not to mention other scripting syntax throughout the course of this thread. Many may not agree, but it's been time well spent for me. RTFM ? Yeah, ok. But which one ? Cordially, Kleeb. |
| |||
| On Wed, 11 Aug 2004 01:36:15 +0000, Kleeb schrieb : <snip> > #!/bin/bash > date > echo "" > echo "Here is the table of all the syndicate numbers ..." echo "" Sorry, wrap. :/ > > 1 xx xx xx xx xx xx 2 xx xx xx > xx xx xx 3 xx xx xx xx xx xx > ... And again ! I'm sure you all know what I mean. Cordially, Kleeb. |
| |||
| Kleeb wrote: > On Tue, 10 Aug 2004 07:47:47 -0500, +Alan Hicks+ schrieb : > >> >> Let me give you the same advice Faux_Pseudo gave me when I was starting >> out. Use the console for everything you possibly can, and for every task >> you find yourself having to do, at least attempt to write a script to do >> it for you. Soon enough you'll be picking things up, learning what >> works, what doesn't. > > Well, I've actually achieved my goal, by using a couple of simple > commands. I've dressed it up to produce an output that I can read more > easily. .... > I've also found out a lot more about grep, sort and uniq, and cat, not to > mention other scripting syntax throughout the course of this thread. Many > may not agree, but it's been time well spent for me. > > RTFM ? Yeah, ok. But which one ? Well, in this case, man grep, man sort, man uniq, and man cat, and maybe a little man bash. Ultimately, of course, all of them. :-) Cheers! Rich |
| |||
| On Tue, 10 Aug 2004 19:08:18 -0700, Jeffrey Froman schrieb : > Kleeb wrote: > >> echo "" > For beautification purposes, note that "echo" by itself on a line does the > same thing :-) Noted. Thanks. Cordially, Kleeb. |
| |||
| On 08-11-2004, in alt.os.linux.slackware, Kleeb <kleeb@kleeb.kleeb> wrote: > On Tue, 10 Aug 2004 19:08:18 -0700, Jeffrey Froman schrieb : > >> Kleeb wrote: >> >>> echo "" >> For beautification purposes, note that "echo" by itself on a line >> does the same thing :-) > > Noted. Thanks. And for non-beautification purposes, 'echo ""' on a line all by itself need not exist at all. Example: |#!/bin/bash |date |echo -e "\nHere is the table of all the syndicate numbers ...\n" #:~$ help echo man 1 echo Max -- For every evil under the sun, There is a remedy, or there is none; If there be one, try and find it, If there be none, never mind it. |
| ||||
| On Thu, 12 Aug 2004 08:35:25 +0000, Max schrieb : > And for non-beautification purposes, 'echo ""' on a line all by > itself need not exist at all. Example: > > |#!/bin/bash > |date > |echo -e "\nHere is the table of all the syndicate numbers ...\n" Thanks. I did see the '\' characters mentioned in the manual, and tried a few. I couldn't get them to work, but from your example, I see that I was putting them in the wrong place. Cordially, Kleeb. |