I'm confused with what to use (awk or grep) in this case as i need to select 2 corresponding patterns. "SName" & "ESys" in a appln config file which looks like this;
This code looks to be working on my first try. Input file is just what i've mentioned in my first question post. In the input file the above mentioned pattern repeats with different SName and ESys values. I'm trying to understand this code; VAL=$0. will this hold SName values?
Could you please go through the following explanation and let me know if this helps you.
awk -F"=" ' ###Set field seprator as "=" here.
/SName/{ ###Looking for string SName in any line, if that is present i any line then perform following.
VAL=$0; ###create variable VAL and assign its value to current line.
next ###next is awk built-in keyword which will SKIP all next statements now.
}
/ESys/ { ###Searching for string "ESys" here in any line, if that is present then perform following.
print VAL,$0 ###Print the value of variable VAL and current line too.
}
' Input_file ###Mentioning the Input_file here, which is getting processes by awk.
Yes. This break-up explanation of the code you gave really helping me. I'm introduced to new form of awk esp. next command, placing current search value in a variable & later printing with the second search pattern. Altogether this is new to me. Thank you very much.