I have the below input and i only want to filter out some un-wanted info from here. Expected output is below. Can somebody help ?
The catch is that i want to grep those lines with term "k=" and lines with term "**" as the 1st column and "07" as the last column. And the number of unwanted lines in between the wanted lines are random. On top of that, the number of field of the wanted lines are also random.
Expected output shown below.
sed's default behaviour is to print out the pattern space it reads. Turn it off with the -n flag.
-e "/k=/p" Look for all lines containing the pattern k= and then print those lines.
-e '/^\*\*.*07$/p' Look for all lines starting with ** and ending with 07 and the print those lines. The ^ is a placeholder for the start of a line and $ is likewise for the end-of-line.
We need to check for actual ** and so escape it as \*\*.
If the file happens to be below (as the input) after using the sed earlier, i would want to cut out those with ABC in the first 3 characters of the 2nd field of those lines with "** ABCXX ZZZ VVV 07" pattern
as shown below and save as another filename. However the number of lines in between the ** pattern is random , fields of such patterm " bbb k= cccc" are random as well.
Can you help me ?
The actual data has random number of lines so we can't take those as reference
but there's a fixed number of fields for "mma k= qqqq".
This is tough to tackle.