Looks like the continuation of your previous thread (see there for sample data); what does not work with above statement? It sucks in the hostlist to compose a large regex, then reads your conf.txt file one configuration entry at a time. If the hostname is NOT found in the regex, the entry is printed. In your above citation, the ! sign in front of the match is missing to EXclude the respective host.
sub("$a", "") definitely is not needed.
Btw, do you want to delete just the hostname or the entire conf entry for that hostname?
Looks like the continuation of your previous thread (see there for sample data); what does not work with above statement? It sucks in the hostlist to compose a large regex, then reads your conf.txt file one configuration entry at a time. If the hostname is NOT found in the regex, the entry is printed. In your above citation, the ! sign in front of the match is missing to EXclude the respective host.
sub("$a", "") definitely is not needed.
Btw, do you want to delete just the hostname or the entire conf entry for that hostname?
thank you so much for correlating this thread to the other thread.
i want to delete just the host name. what's not working is that, this time, i'm running the awk command against a different configuration file. the other configuration file in the other thread was the configuration specifically for hosts.
now, the configuration file i'm working on is the configuration file for the hostgroup(s) of which the host names in the list belong to.
below is an output of this hostgroup configuration file:
Code:
define hostgroup {
alias Virtual Machines Primary Site
hostgroup_name virt-machines-primary
members relay-nasty-01.net,relay-nasty-02.net,relay-nasty-03.net
use generic-hostgroup
}
define hostgroup {
alias Virtual Machines Secondary Site
hostgroup_name virt-machines-secondary
members relay-nasty-04.net,relay-nasty-05.net,relay-nasty-06.net
use generic-hostgroup
}
so when i run the awk command against this configuration file, if it finds, for example, relay-nasty-01.net in the hostgroup called virt-machines-primary, i want it to remove that host name from that group and leave the remaining host names in that group intact UNLESS they're also in the list of host names that the awk is looking to remove.
It loads all host names to compose a regex, and then eliminates any member of the regex from your file. Residual leading and trailing commas have to be eliminated as well.
It loads all host names to compose a regex, and then eliminates any member of the regex from your file. Residual leading and trailing commas have to be eliminated as well.
this works wonderfully.
i think i need a simple modification. after it removes the host name, there is a ",," left in the place of teh host name. this usually happens if the host name is not first in the list.
example:
conf file
Code:
define hostgroup {
alias Virtual Machines Primary Site
hostgroup_name virt-machines-primary
members relay-nasty-01.net,relay-nasty-02.net,relay-nasty-03.net,relay-nasty-03b.net
use generic-hostgroup
}
if i included only "relay-nasty-02.net" in the host list, and i ran the awk command, what results is this:
Code:
define hostgroup {
alias Virtual Machines Primary Site
hostgroup_name virt-machines-primary
members relay-nasty-01.net,,relay-nasty-03.net,relay-nasty-03b.net
use generic-hostgroup
}
if i were to add relay-nasty-03.net to the list of hosts to remove, i get this:
Code:
define hostgroup {
alias Virtual Machines Primary Site
hostgroup_name virt-machines-primary
members relay-nasty-01.net,,,relay-nasty-03b.net
use generic-hostgroup
}
I have a multicolumn text file with header in the first row like this
The headers are stored in an array called . which contains I want to search for each elements of this array from that multicolumn text file. And I am using this awk approach
for ii in ${hdr}
do
gawk -vcol="$ii" -F... (1 Reply)
Hi,
i have another problem. I have been trying to solve it by myself but failed.
inputfile
;;
ID T08578
NAME T08578
SBASE 30696
EBASE 32083
TYPE P
func just test
func chronology
func cholesterol
func null
INT 30765-37333
INT 37154-37318
Link 5546
Link 8142 (4 Replies)
Hi,
here are few lines present in the logs. I want to grep on Error and print few lines before and after Error word is found
line1
Line2
Line3
Error
Line4
Line5
Line6
Line7
I want the output to be
Line2
Line3
Error
Line5 (1 Reply)
Hi,
I have to search a word in a text file and then I have to delete lines above from the word searched . For eg suppose the file is like this:
Records
P1
10,23423432
,77:1
,234:2
P2
10,9089004
,77:1
,234:2
,87:123
,9898:2
P3
456456
P1
:123,456456546
P2
abc:324234 (2 Replies)
Hi all,
I'd like to print the next word after a found pattern.
example text:
word1 word2 word3 word4 pattern word5
pattern word1 word2 word3 word4
word1 word2 pattern word4
basiclly the word after pattern.
Thanks (9 Replies)
Hello!. I am working on a very simple program and I have been trying different things. This is so far what I have done and there is one small detail that still does not work. It finds all the records in a phonebook per say:
./rem Susan
More than one match; Please select the one to remove: ... (3 Replies)
I'm looking for a command that will read a file listing information and delete everything after a certain word is found. I also may need to search the file and delete everything before a certain word. The file would contains fields of information like below repeating for the entire file;
Name... (5 Replies)
I thought that this was going to be quit simple using sed but i wasn't able to find a way to delete the second line of a text file if my pattern was not found in the line
With awk i am completly useless :rolleyes:
Any ideas? (2 Replies)
i have created the following input script
CREATE OR REPLACE VIEW MMSSENDAVGUPLOADTIME_GN
AS
sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_val
sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_counter
select... (1 Reply)
Hi,
For example, i have a string
"123 456 789 abc 111 222 333"
and I would like to delete all the characters before abc so that it becomes
"abc 111 222 333"
how can i do that in unix? using sed?
note: I actually don't know how many words/charachters before "abc", so the "cut"... (9 Replies)