I have a file like below in file allreport.txt:
11:22:33:456 Script started Running: first_script
11:22:34:456 GetData - Read Read 12 Bytes
11:22:34:456 SetData - Write Write 12 Bytes
11:32:33:456 Script started Running: second_script
11:32:34:456 GetData - Read Read 12 Bytes
11:32:34:456 SetData - Write Write 12 Bytes
11:42:33:456 Script started Running: third_script
11:42:34:456 GetData - Read Read 12 Bytes
11:42:34:456 SetData - Write Write 12 Bytes
11:52:33:456 Script started Running: fourth_script
My requirement is that I need to extract the '....' lines which are in between '*scripts'. I tried something like below:
grep 'Running:' allreport.txt | sed 's/[^ ]* //' | cut -d":" -f2 | tr '\n' ' ' | awk -v col=1 '/$col/,/$($col+1)/ allreport.txt > $col'
But after execution of the command I see no output and no result files also created?
How can I achieve the same - the expected output is to have files like first_script, second_script and so on and each of the files contains logs of its run - example first_script should have below lines only:
11:22:34:456 GetData - Read Read 12 Bytes
11:22:34:456 SetData - Write Write 12 Bytes
Similarly second_script should have below lines and so on:
11:32:34:456 GetData - Read Read 12 Bytes
11:32:34:456 SetData - Write Write 12 Bytes