I have figured out how to grep the file like this:
The above line does echo the correct information from the lines in which my search criteria is found.
Now I am trying to get that information (Yes, just one column of every line) into an array.
I would like each line to have a place in the array automatically.
EXAMPLE:
I have been trying everything that I could think of and I can't get my array populated.
Is there a way to do the above? grep line by line into an array without a loop?
I wish to thank everyone in advance for their assistance.[/HTML]
---------- Post updated at 12:07 PM ---------- Previous update was at 11:42 AM ----------
I have tried doing this:
It seems that it is just writing each line into the variable MyArray and the last line is the one that is left. I know that I am missing something really simple but I can't seem to figure it out.
Last edited by Scott; 09-17-2010 at 02:34 PM..
Reason: Please use code tags
Hallo,
ich habe eine Datei "Kino.ini" die z.B. wie folgt aussieht
* KINOFILM A
bla bla
KINOFILM B
blubb blubb
KINOFILM C
Ich möchte nun die Datei "Kino.ini" per cat und grep auslesen und testen ob der String KINOFILM nur mit einem '*' am Anfang vorkommt. In dieser Beispieldatei... (3 Replies)
Hi,
I'm trying to write a function that redirects the contents of an
array to a file. The array contains the lines of a data file with
white space.
The function seems to preserve all white space when redirected
except that it seems to ignore newlines. As a consequence, the
elements of the... (7 Replies)
Hi Guys,
I have a file which has numbers in it separated by newlines as follows:
1.113
1.456
0.556
0.021
-0.541
-0.444
I am using the following code to store these in an array in bash:
FILE14=data.txt
ARRAY14=(`awk '{print}' $FILE14`) (6 Replies)
Hi,
I'm trying to write a bash script that takes a file and passes each line from the file into an array with elements separated by column.
For example:
Sample file "file1.txt":
1 name1 a first
2 name2 b second
3 name3 c third
and have arrays such as:
line1 = ( "1" "name1" "a"... (3 Replies)
I need following code in linux bash:
Step 1:
run a command and create file1
run a command and create file2
compare file1 and 2
if any difference go to step 1 (keep trying 4 times, if no success, abort program)
else do nothing and continue program.
now I'm... (2 Replies)
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)
#!/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! (5 Replies)
Hi guys and gals...
MacBook Pro.
OSX 10.13.2, default bash terminal.
I have a flat file 1920 bytes in size of whitespaces only. I need to put every single whitespace character into a bash array cell.
Below are two methods that work, but both are seriously ugly.
The first one requires that I... (7 Replies)
The bash stores each uniqueid in an array and then passes them to %q to get the unique path. That seems to work what I am having trouble with is renaming each .png with the unique value in %q. I thought it was working but upon closer inspection, a .png file is being sent to scp.... but only 1 and... (21 Replies)
This is the sample json I have pasted here. I want all the IP address strings to be converted into an array. For example "10.38.32.202" has to be converted to everywhere in the JSON. There are multiple IPs in a JSON I am pasting one sample object from the JSON. But the IPs already in an Array... (11 Replies)