Sponsored Content
Top Forums Shell Programming and Scripting Pick a card from an array in bash Post 302535304 by Pouchie1 on Thursday 30th of June 2011 11:12:19 AM
Old 06-30-2011
Pick a card from an array in bash

Hello,

I am trying to use $RANDOM to pick cards from an array in bash. I created the script below to give me a selection everytime I run it, but the output is always like this:
2 3 4 5 6 7 8 9 10 Jack Queen King Ace of Clubs Diamonds Hearts Spades.

Can you please help me? I expected it to give me something like : 2 of Jack or 5 of Hearts, everytime I run it. the codes are below

Code:
 
#!/bin/bash
suite="Clubs Diamonds Hearts Spades"
denomination="2 3 4 5 6 7 8 9 10 Jack Queen King Ace"
num_suites=${#suite[*]}
num_denominations=${#denomination[*]}
echo -n "${denomination[$((RANDOM%num_denominations))]} of "
echo "${suite[$((RANDOM%num_suites))]}"
exit 0

 

10 More Discussions You Might Find Interesting

1. Linux

Wireless card won't pick up network

I'm trying to get my wireless card up. I've been at it for a while now and something just isn't quite working right. I'm not getting any wireless signal. I'm using FC4 with a stack 16 kernel and ndiswrappr to load my drivers. here are the outputs that i get. Alittle bit about my... (3 Replies)
Discussion started by: byblyk
3 Replies

2. Shell Programming and Scripting

bash array

I'm trying to move files based on a certain day..my question is on array's, what's wrong with the way I'm stepping through the array? what i have gives me syntax errors..any ideas...so far I have #! /bin/bash sun_d=`cal |grep -v |awk '{printf " " $1}' ` echo "$sun_d" ls -l... (1 Reply)
Discussion started by: gubten
1 Replies

3. UNIX Desktop Questions & Answers

Does Red Hat Fedora support Nvidia card 8800GTX and 260 card?

Does Red Hat Fedora support Nvidia card 8800GTX and 260 card? Does any Linux OS support Nvidia card? (1 Reply)
Discussion started by: sito
1 Replies

4. Shell Programming and Scripting

Array in Bash!

sorry I am new to the bash scripting since I was used to c shell programming. I am writting a script in bash for which I have to create an array in bash. I was able to do parse one variable through command line by doing": Lets say the below code is part of temp.bash and is called like: temp.bash... (5 Replies)
Discussion started by: dixits
5 Replies

5. OS X (Apple)

Associated Array in bash

I am using code as below to save data in associated array on Mac OS 10.8. #!/bin/sh storyboardExt=".storyboard" stringsExt=".strings" newStringsExt=".strings.new" oldStringsExt=".strings.old" localeDirExt=".lproj" baseLprojDir="Base${localeDirExt}" echo "${baseLprojDir}" # Find... (2 Replies)
Discussion started by: mikezang
2 Replies

6. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

7. Shell Programming and Scripting

Pick a line in file 2 basing on array in file1

Dear friends, I have two files. One with all IDs(in a single field) . And another with data(of which say field 5 is ID). I want to create an array of IDs using first file and while reading second file if the ID appears in the array I need to print $0 else skip. After a long gap I am... (6 Replies)
Discussion started by: paresh n doshi
6 Replies

8. UNIX for Dummies Questions & Answers

Help with bash array

Hi, I would like to remove audio tracks from several video clips contained in a single directory using the command files=(*.mpg); ffmpeg -i "${files}" -vcodec copy -an na/output.mpg I want each processed file outputted to the sub-directory na retaining the original file name, how do I do that?... (4 Replies)
Discussion started by: jeppe83
4 Replies

9. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

10. Shell Programming and Scripting

Bash Array connectin to another Array

Hello, i have a script that i need account_number to match a name. for exsample : ACCOUNT_ID=(IatHG8DC7mZbdymSoOr11w KbnlG2j-KRQ0-1_Xk356s8) and i run a loop curl requst with this the issue is that i want to know on which account were talking about so bash will know this : ... (4 Replies)
Discussion started by: batchenr
4 Replies
SN(4)							   BSD Kernel Interfaces Manual 						     SN(4)

NAME
sn -- Ethernet driver for SMC91Cxx based cards SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device sn Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): if_sn_load="YES" DESCRIPTION
The sn device driver supports SMC91Cxx based ISA and PCMCIA cards. HARDWARE
The sn driver supports SMC91Cxx based ISA and PCMCIA cards including: o 3Com Megahertz X-Jack Ethernet PC Card XJ10BT, XJ10BC o 3Com Megahertz XJEM and CCEM series: CCEM3288C, CCEM3288T, CCEM3336, CEM3336C, CCEM3336T, XJEM1144C, XJEM1144T, XJEM3288C, XJEM3288T, XJEM3336 o Farallon EtherMac PC Card 595a o Motorola Mariner Ethernet/Modem PC Card o Ositech Seven of Diamonds Ethernet PC Card o Ositech Jack of Hearts Ethernet/Modem PC Card o Psion Gold Card Netglobal Ethernet PC Card o Psion Gold Card Netglobal 10/100 Fast Ethernet PC Card o Psion Gold Card Netglobal 56k+10Mb Ethernet PC Card o SMC EZEther PC Card (8020BT) o SMC EZEther PC Card (8020T) The sn driver supports the SMC 91C90, SMC 91C92, SMC 91C94, SMC 91C95, SMC 91C96, SMC91C100 and SMC 91C100FD chips from SMC. The Farallon EtherWave and EtherMac card came in two varieties. The ep(4) driver supports the 595 and 895 cards. These cards have the blue arrow on the front along with a 3Com logo. The Farallon 595a cards, which have a red arrow on the front, are also called EtherWave and EtherMac. They are supported by the sn driver. SEE ALSO
ed(4), ep(4), ie(4), intro(4), ng_ether(4), vx(4), ifconfig(8) HISTORY
The sn device driver appeared in FreeBSD 4.0. BSD
July 16, 2005 BSD
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy