How to print elements between letters bash script?
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:
String for case 2:
The strings are separated by "U" followed by "V", this is "UV", but sometimes U or V appears alone (not in sequence UV). I want to print the elements between UV concatenated in a single string.
For String 1 the array is 1rst one and the output would be:
and I'm only getting 81, 78 and 89800.
for String 2 the array is 2nd one "commented" and the output would be:
and I'm only getting 8, 78 and 18.
The code I have so far is:
PS: The data is stored in arrays initially but I show you the way the data looks in a string for you to understand better. I'm using Cygwin.
Thanks in advance for any help.
Last edited by jim mcnamara; 12-17-2014 at 05:35 PM..
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)
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)
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)
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)
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)
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)
hey
i m kinda new to this so i will appreciate any help
, i have this list of values:
pwwn = 0x50012482009cd7a7 nwwn=0x50012482009cd7a6 port_id = 0x280200
pwwn = 0x5001248201bcd7a7 nwwn=0x5001248201bcd7a6 port_id = 0x280300
pwwn = 0x50012482009c51ad nwwn=0x50012482009c51ac port_id =... (4 Replies)
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)
hi Im trying to make the 'response' return the answer in the form of a dash (-) rather than the actuall letters of a given word typed in, this is what i have tried, but im not getting the dashes come through just a blank screen, any ideas guys?
function enterWord () {
echo "select to be... (2 Replies)
Hi,
I have a file which has the below information
tm.orbit72
tm.orbit12
tm.orbit78
tm.orbitye
I want to print the last two letters in the above file. Please let me know how can i do that. (6 Replies)