Unix Technical Forum

OT : Match number-string script ?

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, ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 02-19-2008, 02:36 PM
Rich Grise
 
Posts: n/a
Default Re: OT : Match number-string script ?

Bryan Bibb wrote:

.... contumacious ...

Geez! One that even _I_ had to look up! And in so doing, I learned
a new word.

I Contemn Authority.

Cheers!
Rich

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 02-19-2008, 02:37 PM
Kleeb
 
Posts: n/a
Default Re: OT : Match number-string script ?

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.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 02-19-2008, 02:37 PM
Kleeb
 
Posts: n/a
Default Re: OT : Match number-string script ?

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 02-19-2008, 02:37 PM
Jeffrey Froman
 
Posts: n/a
Default Re: OT : Match number-string script ?

Kleeb wrote:

> echo ""

For beautification purposes, note that "echo" by itself on a line does the
same thing :-)

Jeffrey
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 02-19-2008, 02:37 PM
Rich Grise
 
Posts: n/a
Default Re: OT : Match number-string script ?

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 02-19-2008, 02:38 PM
Kleeb
 
Posts: n/a
Default Re: OT : Match number-string script ?

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 02-19-2008, 02:40 PM
Max
 
Posts: n/a
Default Re: OT : Match number-string script ?

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 02-19-2008, 02:40 PM
Kleeb
 
Posts: n/a
Default Re: OT : Match number-string script ?

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:46 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com