Hi,
trying to knock something together to create one line entries based on whether the first word on each line matches a particular value.
eg.
Link,"Name=""Something\something"","Timeout=""1800""",
"Target=""\\thing\thing\thing""","State=""ONLINE""",something,
"Target=""\\thing\thing\thing""","State=""OFFLINE""",otherthing,
Link,"Name=""Something\somethingo""","Timeout=""300""",
"Target=""\\\thing\thing\thing""","State=""ONLINE""",otherthing,
"Target=""\\\\thing\thing\thing""","State=""OFFLINE""",otherthing,
Link,"Name=""something\something""","Timeout=""1800""",
"Target=""\\thing\thing\thing""","State=""ONLINE""",otherthing,
"Target=""\\thing\thing\thing""","State=""OFFLINE""",otherthing,
is some example data.
I want to have a single line of data starting from each entry beginning 'Link'
and adding entries from the following lines until we reach the next line containing 'Link' when I want to start a new line and repeat the process.
The number of lines containing 'Target' can vary.
I guess something in awk would be the preferred but i'll try anything.
thanks
Ad
---------- Post updated at 04:32 AM ---------- Previous update was at 04:13 AM ----------
Solved:
awk '/Link/{if (x)print x;x="";}{x=(!x)?$0:x","$0;}END{print x;}' file.txt