10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
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 the random number generator
BEGIN { srand() }
## Put a random number in front... (4 Replies)
Discussion started by: cogiz
4 Replies
2. UNIX for Beginners Questions & Answers
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
Cogiz
Please use CODE tags as required by forum rules! (3 Replies)
Discussion started by: cogiz
3 Replies
3. UNIX for Beginners Questions & Answers
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?
This is a part of a Terminal game of Crazy 8's that I'm attempting to write in Bash.
Any... (2 Replies)
Discussion started by: cogiz
2 Replies
4. Shell Programming and Scripting
Hello experts,
I wish to print the contents of odd-even numbered indices of an array.
The problem statement is as follows :
1. The first line contains an integer, (the number of test cases).
2. Each line of the subsequent lines containing a string.
Example:
2
Haider
Bash
... (4 Replies)
Discussion started by: H squared
4 Replies
5. Shell Programming and Scripting
Hi All,
need help with reading the array and sum of the array elements.
given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large.
Input Format
The first line of the input consists of an... (1 Reply)
Discussion started by: nishantrefound
1 Replies
6. UNIX for Dummies Questions & Answers
Hello,
In a shell script, I want to declare an array and subsequently print the elements with tab delimits.
My array has the following structure and arbitrary elements:
myArray=('fgh' 'ijk' 'xyz' 'abc');
Next, I would like to print it with a '\n' at the end.
Thanks for your input!
... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies
7. Shell Programming and Scripting
Hello to all,
May somebody help me to fix my bash code below, I'd like to do it only using loops and if statements is possible.
I the content of the arrays are represented by the following 2 strings, where each character is an element inside the array.
String for case 1:... (10 Replies)
Discussion started by: Ophiuchus
10 Replies
8. Shell Programming and Scripting
Hey guys,
I'm new to shell scripting and I'm trying to write a script that takes user input and copies the specified columns from a data file to a new one. In order to account for the possibility of a variable number of columns to copy I wrote a loop that encodes the user's choices in an array... (16 Replies)
Discussion started by: shaner
16 Replies
9. Shell Programming and Scripting
I am creating a report in groff and need to format data from a file into a
table cell.
Sample data:
dador,173323,bpt,jsp,39030013338878,1
dador,173323,brew,jsp,39030013338860,1
dador,173323,brew,jsp,39030013339447,1
dador,173323,brew,jsp,39030013339538,1
I would like to build a table... (12 Replies)
Discussion started by: Bubnoff
12 Replies
10. UNIX for Dummies Questions & Answers
Hi friends how can we read array elements dynamically in bash shell? (1 Reply)
Discussion started by: haisubbu
1 Replies