10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have an array code and output is below:
echo $1
while read -r fline; do
echo "%%%%%%$fline%%%%%"
fmy_array+=("$fline")
done <<< "$1"
Output:
CR30903 YU0007 SRIL CR30903 Yogesh SRIL
%%%%%%CR30903 YU0007 SRIL%%%%%
%%%%%%CR30903 Yogesh SRIL%%%%%
... (8 Replies)
Discussion started by: mohtashims
8 Replies
2. 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
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
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
5. Shell Programming and Scripting
Hi
I wanted to print random elements from an array at bash shell
I use the following code, but I always see first element getting printed
#!/bin/bash
c=1
expressions=(pink red white yellow purple)
while ]; do
echo "The value of RANDOM is $RANDOM"
selectedexpression=${expressions}]};... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies
6. Shell Programming and Scripting
Hi,
I can't find out how to create correct code to get multiplication of each elements of array. Let's say I enter array into command line (2 3 4 5 6 8) and i need output 2*3*4*5*6*8=5760.
I tried this one, but answer is 0.
for i in $@; do
mult=$((mult*i))done
echo "mult: " $mult
... (4 Replies)
Discussion started by: rimasbimas
4 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I have an array containing following sample information
@array = qw (chr02 chr02 chr02 chr02 chr02 chr03 chr03 chr04 chr04 chr05 chr05 chr05 chr07 chr07) I need to replace all duplicate entries by an underscore to get the following output@array = qw (chr02 _ _ _ _ chr03 _ chr04 _ chr05 _ _... (4 Replies)
Discussion started by: pawannoel
4 Replies
8. Shell Programming and Scripting
Hi Guys,
I have an array which has numbers including blanks as follows:
1
26
66
4.77
-0.58
88
99
11
12
333
I want to print a group of three elements as a different column in a file as follows:(including blanks where there is missing elements) for.e.g. array element #7... (4 Replies)
Discussion started by: npatwardhan
4 Replies
9. Shell Programming and Scripting
How can I get my array to understand the double-quotes I'm passing into it are to separate text strings and not part of an element? here's what I'm working with...
db2 -v connect to foo
db2 -x "select '\"' || stats_command || '\",' from db2law1.parallel_runstats where tabname = 'BAZ'"
set... (4 Replies)
Discussion started by: djschmitt
4 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