Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Lottery result checker

Shell Programming and Scripting


Tags
bash, lottery

Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 1 Week Ago   -   Original Discussion by PuLPi
RudiC's Unix or Linux Image
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 January 2018, 3:28 AM EST
Location: Aachen, Germany
Posts: 11,966
Thanks: 354
Thanked 3,688 Times in 3,386 Posts
Slightly different approach borrowing from rdrtx1:


Code:
awk '
NR == 1   {printf("%-25s\t%-25s\t%-10s\t%-10s\n", "Winning Numbers", "My Numbers", "#s Matched", "Result")
           for (n=split ($0, TMP); n>0; n--) MYNO[TMP[n]]
           MN = $0
           split ("win lose", RES)
           next
          }

    {for (i=1; i<=NF; i++)    c += ($i in MYNO)
     printf "%-25s\t%-25s\t%-10d\t%-10s\n", $0, MN, c, RES[1+(c < 4)]
     c = 0
    }
' my_numbers winning_numbers

For your new request, I'm not quite sure I understand it. How about rephrasing it? Not the original requestor.

Last edited by RudiC; 1 Week Ago at 09:30 AM..
Sponsored Links
    #9  
Old Unix and Linux 1 Week Ago   -   Original Discussion by PuLPi
rdrtx1's Unix or Linux Image
rdrtx1 rdrtx1 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 21 January 2018, 10:35 PM EST
Location: Houston, Texas, USA
Posts: 1,021
Thanks: 0
Thanked 352 Times in 333 Posts
Quote:
Originally Posted by gsiva View Post
Hi Rdrtx1,

Assume if I have the shuffled numbers from 1 to 35 and I don't want to check all the number from 1-35, whereas, I need to check the number randomly on my own.
How can this be achieved.
The script shown in post #2 on this thread only checks for numbers as defined by PuLPi's posted lottery number generator (7 randomly picked numbers, not all 35). The script also generates the "my_numbers" file the same way (7 randomly picked numbers but can be more or less numbers). The input of the "my_numbers" can be change as needed. If the numbers are to be input manually then a prompt can be used to read the numbers (on a loop if entered one by one) or the numbers can be read from an existing file.
Sponsored Links
    #10  
Old Unix and Linux 3 Days Ago   -   Original Discussion by PuLPi
gsiva's Unix or Linux Image
gsiva gsiva is online now
Registered User
 
Join Date: Dec 2008
Last Activity: 22 January 2018, 3:23 AM EST
Location: Singapore
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb

hi ,

Let me put it in a different way with words.

1) Assume the lottery have numbers from 1-50.
2) Out of this 50 numbers, I am going to pick up only 35 numbers randomly.
3) so, my total numbers would be 35 numbers shuffled from [1-50] nos.
[eg: 1,4,6,7,11,30,32,40,46,49]

4) I have list of winning numbers in [my_number.txt] file.
5) Now, the script should check within my 35 numbers comparing the file [my_number.txt] and should give the results .. The result number should be 6 nos.
[eg: 1 6 30 32 46 49 ]

Thanks in Advance.

-Siva
    #11  
Old Unix and Linux 2 Days Ago   -   Original Discussion by PuLPi
RudiC's Unix or Linux Image
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 January 2018, 3:28 AM EST
Location: Aachen, Germany
Posts: 11,966
Thanks: 354
Thanked 3,688 Times in 3,386 Posts
Moderator's Comments:
Lottery result checker DON'T hijack others' posts! Create your own, new thread!

This thread is closed.

Last edited by RudiC; 2 Days Ago at 05:22 AM..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to compare the current result with previous line result.? ken6503 Shell Programming and Scripting 1 05-05-2015 03:41 PM
This Weeks Lottery - Jackpot Now 219,500 Bits Neo What is on Your Mind? 0 05-28-2009 02:05 PM
display the result of wc -l with words before and after the result melanie_pfefer UNIX for Dummies Questions & Answers 3 04-30-2008 08:33 AM
Proxy Checker in C magictalong Programming 0 10-23-2007 01:54 AM



All times are GMT -4. The time now is 04:30 AM.