Search Results

Search: Posts Made By: cogiz
4,317
Posted By cogiz
Thank you very much for all of your help and...
Thank you very much for all of your help and suggestions...it pointed me in the right direction.

I used the following in my script:


tput cup 4 10
echo ${PH[@]:0:24}
tput cup 6 10
echo...
4,317
Posted By cogiz
Limiting Bash array single line output
#!/bin/bash

PH=(AD QD QC 5H 6C 8C 7D JH 3H 3S)

echo ${PH[@]}


In the above array, how can I print to screen just the first 8 elements of ${PH[@]} and have the last 2 elements print just...
945
Posted By cogiz
Cherry picking with sed?
#!/bin/bash

shuffle()
{
Deck=$(shuf -e {2,3,4,5,6,7,8,9,T,J,Q,K,A}{H,S,D,C})
}

PH=(6H 9S KC) # playerhand
CH=(JD 4D) # computerhand
AC=2S # activecard

shuffle...
785
Posted By cogiz
Grep trouble in Bash
PH=(6H 0 0 JD 9S 0 KD 0) #input from .txt file

In the above array, I am trying to get the computer to tell me at what indices the non-zeros are at.

I don't understand why this doesn't...
964
Posted By cogiz
inaccurate scanning of Bash array....SOLVED
Thank you very much for your suggestions. The following worked like a charm:


read X < /home/cogiz/activecard.txt
A=${X%?}
B=${X#?}
C=8


Now the scanning of ${PH[@]} for $A|$B|8 works...
964
Posted By cogiz
Inaccurate scanning of Bash array elements
username=cogiz
#!/bin/bash

shuffle() #@ USAGE: shuffle
{ #@ TODO: add options for multiple or partial decks
Deck=$(
printf "%s\n" {2,3,4,5,6,7,8,9,T,J,Q,K,A}{H,S,D,C} |
awk '## Seed...
621
Posted By cogiz
If then statement confusion
#!/bin/bash
PH=(KD 6S TC 3D) #playerhand
TCIP=(AH) #topcard in play
A=( "${TCIP[@]::1}" ) # A
B=( "${TCIP[@]:1}" ) # H...
756
Posted By cogiz
sed confusion
#!/bin/bash
X=(0 2 4 6 7 0 0 0 0)

Let me just say from the start that sed confuses the hell out of me!

In the above line of code how can I use sed to remove all of the 0's except the first...
1,439
Posted By cogiz
Thank you. It makes more sense now. Cogiz
Thank you. It makes more sense now.

Cogiz
1,439
Posted By cogiz
unset array elements in Bash
Thank you for your reply.

In this particular case X represents the computer's hand in a game of crazy 8's. The 10D is the card that the computer has chosen to play for its turn. So I need to...
1,439
Posted By cogiz
Unset array element and save to file in Bash
#!/bin/bash

X=(2H 4S 10D QC JD 9H 8S)

How do I unset the 10D from this array and save it to a file?


Please use CODE tags as required by forum rules!
25,605
Posted By cogiz
Random choice of elements in bash array
example of problem:

#!/bin/bash

P=(2 4 7)

How would you randomly choose one of these 3 numbers in this array?

either 2 or 4 or 7 is needed...but only one of them.

Thanks in advance...
732
Posted By cogiz
Connecting and changing variables in Bash script
#!/bin/bash

X=$(</home/cogiz/computerhand.txt) # (3S 8C 2H 6D QC 8S 4H 5H)
Y=$(</home/cogiz/topcardinplay.txt) # KS
A=( "${Y[@]::1}" )
B=( "${Y[@]:1}" )
...
2,879
Posted By cogiz
Output to file print as single line, not separate line
example of problem:

when I echo "$e" >> /home/cogiz/file.txt

result prints to file as:AA
BB
CC

I need it to save to file as this:AA BB CC

I know it's probably something really simple...
1,569
Posted By cogiz
thank you very much. It worked like a charm ...
thank you very much. It worked like a charm

Cogiz
1,569
Posted By cogiz
Scanning array for partial elements in Bash Script
Example of problem:

computerhand=(6H 2C JC QS 9D 3H 8H 4D)
topcard=6D

How do you search ${computerhand[@]} for all elements containing either a "6" or a "D" then
save the output to a file?
...
2,801
Posted By cogiz
proper distribution of cards in BASH terminal based crazy8's game SOLVED!
Thank you very much for your very helpful suggestion. I have solved that particular problem by adjusting my script as follows:

#!/bin/bash

# Date="November, 2016"
# Author/Constructor="Steve...
2,801
Posted By cogiz
Proper distribution of cards in terminal based crazy8's game in bash script
When I run the following script at the bottom it say cards remaining=44...It should be=35.
Can anyone tell me what I'm doing wrong. I've spent hours trying to get this to work and I can't go any...
1,131
Posted By cogiz
Array problem in Bash script
I would like to officially thank all the people who offered advice on my problem. I can say for sure that the problem has been solved by populating an empty array from a txt file and saving output to...
1,131
Posted By cogiz
Array problem in Bash script
Thank you for suggestions. I am writing a little script that will keep track of current medications (dosage, supply, refills, etc.) and send an email when it is time for the prescription to be...
1,131
Posted By cogiz
Array problem in Bash Script
I am trying to write a Bash Script using a couple of arrays. I need to perform a countdown of sorts on an array done once daily, but each day would start with the numbers from the previous day. This...
Showing results 1 to 21 of 21

 
All times are GMT -4. The time now is 04:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy