Hi,
I am working on an awk utility that manipulates the following two files
a, A file with a list of files (final.txt)
The contents of the "final.txt" files are as follows
./test_data/allstream_bss_cfg.xml
./test_data/ss_ma_bss_cfg.xml
b, A file with "search" and "replace" patterns (source_target_strings.txt)
The contents of the "source_target_strings.txt" file are as follows
47.150.56.224,47.150.56.999
16701,99999
PS: source and target strings are comma delimited
The idea here is to search & replace some IPs, host names etc from all the files.
My utility looks as follows
# awk script is invoked on each line of "final.txt"
# Search & replace strings
#
BEGIN { }
{ print $0
while( getline < "source_target_strings.txt")
{
# Extract the source and target strings
split($0, a, ",")
target = a[0];
source = a[1];
print a[0];
print a[1];
system("nawk '{/target/source/g }' $0");
}
close("source_target_strings.txt");
}
From the command line, I invoke the awk utility as follows
nawk -f reconfigure.awk final.txt
I need help with the syntax for passing the correct parameters (i.e. target, source, and file name) on the system call.
Thanks in advance.
rogers42
I am working on an awk utility that manipulates the following two files
a, A file with a list of files (final.txt)
The contents of the "final.txt" files are as follows
./test_data/allstream_bss_cfg.xml
./test_data/ss_ma_bss_cfg.xml
b, A file with "search" and "replace" patterns (source_target_strings.txt)
The contents of the "source_target_strings.txt" file are as follows
47.150.56.224,47.150.56.999
16701,99999
PS: source and target strings are comma delimited
The idea here is to search & replace some IPs, host names etc from all the files.
My utility looks as follows
# awk script is invoked on each line of "final.txt"
# Search & replace strings
#
BEGIN { }
{ print $0
while( getline < "source_target_strings.txt")
{
# Extract the source and target strings
split($0, a, ",")
target = a[0];
source = a[1];
print a[0];
print a[1];
system("nawk '{/target/source/g }' $0");
}
close("source_target_strings.txt");
}
From the command line, I invoke the awk utility as follows
nawk -f reconfigure.awk final.txt
I need help with the syntax for passing the correct parameters (i.e. target, source, and file name) on the system call.
Thanks in advance.
rogers42