Trying to use a variable pulled from a for statement in a search string
Guys I am having trouble trying to pull some data from a file using a value returned from a for statement. Any help would greatly be apprecaited. I can't seem to get my script to pass the variable. I am trying to pull the 2 lines below the line that has the "pool name" so that i can get the monitor information.
Raw Data file that I am pulling data from example of file. There is a bunch more (200,000 lines to be exact) data in the file but for example here I pared it down to what I am searching for:
Code:
pool Happy_9120_Pool {
lb method member observed
monitor all System_Dead and I_don't_wanna_work_Monitor_9120
members
1.2.3.1:9120
1.2.3.2:9120
1.2.3.3:9120
1.2.3.4:9120
}
pool Happy_9121_Pool {
lb method member observed
monitor all System_Dead and I_don't_wanna_work_Monitor_9121
members
1.2.3.1:9121
1.2.3.2:9121
1.2.3.3:9121
1.2.3.4:9121
}
pool Happy_9122_Pool {
lb method member observed
monitor all System_Dead and I_don't_wanna_work_Monitor_9122
members
1.2.3.1:9122
1.2.3.2:9122
1.2.3.3:9122
1.2.3.4:9122
}
Extracted Date file that I am searching for and example of file. The pool name is the only thing in this file:
Code:
Happy_9120_Pool
Happy_9121_Pool
Happy_9122_Pool
Expected/Desired Output:
Code:
pool Happy_9120_Pool {
lb method member observed
monitor all System_Dead and I_don't_wanna_work_Monitor_9120
pool Happy_9121_Pool {
lb method member observed
monitor all System_Dead and I_don't_wanna_work_Monitor_9121
pool Happy_9122_Pool {
lb method member observed
monitor all System_Dead and I_don't_wanna_work_Monitor_9122
My Script that I am trying to make work:
Code:
config=/mnt/pool_data_file
config1=/mnt/raw_data_file
tempfile=/mnt/configs_to_delete.txt
for i in `cat $config`
do
echo $i
awk '/pool $i {/{getline;print;getline;print}' $config1
done
Hi, guys. I have one question:
I need to search for a string in a file, and then extract another string from the file and assign it to a variable.
For example:
the contents of the file (group) is below:
...
ftp:x:23:
mail:x:34
...
testing:x:2001
sales:x:2002
development:x:2003
...... (6 Replies)
Hi
I want to read a file line by line and search for a particular string in each line(say for example string containing @ )and save that string into a variable.
Can someone suggest me the way to implement it.I am using K- shell
Thanks
Ishita (5 Replies)
guys,
I need to know how to assing pattern matched string as an input command variable. Here it goes'
My script is something like this.
./routing.sh <Server> <enable|disable>
## This Script takes an input <Server> variable from this line of the script ##
echo $1 | egrep... (1 Reply)
Hi,
We Perfrom Loads to the database through a Perl script which generates a statistics file. I need to read the statistics. the Statistics file looks something like below:
Process Beginning - 08-26-2010-23.41.47
DB2 CONNECTION SUCCESSFUL!
Ready to process and load file: FILENAME
# of... (2 Replies)
hi,
trying to learn more abt sed :(
i want to substitute a variable(a) with other variable(b) appended.
Read.txt contains:
home/test2/abc
home/test/root1
input.txt contains:
make test "home/test1/none"version="1.3"
wt's wrong test "home/test2/abc"version="1.0"
make save... (9 Replies)
Hi,
I'm trying to search a text file for a string: "energy(sigma->0)=". To do so, I executed the grep command, which returned many matches, for example:
energy without entropy = -112.16486170 energy(sigma->0) = -112.16520778
energy without entropy = -112.16488936 ... (5 Replies)
I have a file with
<suit:run date="Trump Tue 06/19/2012 11:41 AM EDT" machine="garg-ln" build="19921" level="beta" release="6.1.5" os="Linux">
Need to find word "build" then
extract build number, which is 19921 also
release number, which is 6.1.5 then
concatenate them to one variable as... (6 Replies)
I must have forgot how to do this, but, I am attempting to enter a variable into an awk / gawk search pattern.
I am getting a value from user input to place in a specific section of a 132 character string.
my default command is ....
gawk --re-interval '/^(.{3}P .{4}CYA.{8}1)/' ... (3 Replies)
I'm interested to match column pattern through awk using an external variable for data:
-9 1:751343:T:A -9 0 T A 0.726 -5.408837e-03 9.576603e-03 7.967536e-01 5.722312e-01
-9 1:751756:T:C -9 0 T C 0.727 -5.360458e-03 9.579447e-03 7.966977e-01 5.757858e-01... (7 Replies)
Hi,
I have a working script.
It does what I am intending it to but a bit confused whether the sed part is supposed to be working or not. Further down is the script with the sed part that should have been working but not and the grep -v part which is the workaround that I am using at the... (10 Replies)