Hello World (my first question here :)
I have one file containing two fields.
I want awk
to use one field as the input file for the search of the other field.
Lets say the input file looks like:
CONFIG_file123;configelement_ABC
CONFIG_file124;configelement_XYZ
Now I want awk
to read field 1 (CONFIG_file123
)and use it as input file where it searches for field 2 (configelement_ABC
) outputs that and proceeds then to the next line in the input file.
Like this:
awk 'BEGIN{ RS = "\n"; ORS="\n" } {if ($0 ~ /configelement_ABC/) { print FILENAME ";" $0 }}' CONFIG_file123
Thank you very much in advance!
if this helps:
CONFIG_file123
configelement_ABA Data1 Data2 Data3
configelement_ABB Data1 Data2
configelement_ABC Data1
configelement_ABD Data1 Data2 Data3
configelement_XYW Data1 Data2
configelement_XYX Data1 Data2 Data3
configelement_XYY Data1
configelement_XYZ Data1 Data2 Data3
CONFIG_file124
configelement_ABA Data1 Data2 Data3
configelement_ABB Data1 Data2
configelement_ABC Data1 Data2
configelement_ABD Data1 Data2 Data3
configelement_XYW Data1 Data2
configelement_XYX Data1 Data2 Data3
configelement_XYY Data1 Data2
configelement_XYZ Data1 Data2
Output
CONFIG_file123;configelement_ABC Data1
CONFIG_file124;configelement_XYZ Data1 Data2