I am rsyncing and remotely doing some work based on a logfile from a windows box from a centos backup server. I get the output from a vss snapshot that has a section like this: * SNAPSHOT ID = {639ef5df-c933-4496-878a-ed57b9d52876} ... - Shadow copy Set: {427ac5db-21be-4c53-8ca4-24e7bac86a1d} - Original count of shadow copies = 2 - Original Volume name: \\?\Volume{787bdf7a-ccff-11dd-9866-806e6f6e6963}\ [D:\] - Creation Time: 6/10/2009 12:12:08 PM - Shadow copy device name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy11 - Originating machine: milano.example.local - Service machine: milano.example.local - Not Exposed - Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5} - Attributes: No_Auto_Release Persistent Differential * SNAPSHOT ID = {fb5996cf-a35b-4110-b83c-45f9c64a75f3} ... - Shadow copy Set: {427ac5db-21be-4c53-8ca4-24e7bac86a1d} - Original count of shadow copies = 2 - Original Volume name: \\?\Volume{787bdf7b-ccff-11dd-9866-806e6f6e6963}\ [E:\] - Creation Time: 6/10/2009 12:12:08 PM - Shadow copy device name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy12 - Originating machine: milano.example.local - Service machine: milano.example.local - Not Exposed - Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5} - Attributes: No_Auto_Release Persistent Differential My current script only uses sed/grep but I never had to deal with this case where now I need to do something based on the grep'ed/sed extraction of the value of "SNAPSHOT ID" based on volume name "D:" or "E:"? To make my script work without rewriting it, is there a sed method to only take the "SNAPSHOT ID" if the text indented beneath it has "D:", then do the same and extract "SNAPSHOT ID" if and only if "E:" follows? Thanks for any help! jlc
On Wed, 2009-06-10 at 18:18 +0000, Joseph L. Casale wrote:> I am rsyncing and remotely doing some work based on a logfile from > a windows box from a centos backup server. I get the output from a > vss snapshot that has a section like this: > > * SNAPSHOT ID = {639ef5df-c933-4496-878a-ed57b9d52876} ... > - Shadow copy Set: {427ac5db-21be-4c53-8ca4-24e7bac86a1d} > - Original count of shadow copies = 2 > - Original Volume name: \\?\Volume{787bdf7a-ccff-11dd-9866-806e6f6e6963}\ [D:\] > - Creation Time: 6/10/2009 12:12:08 PM > - Shadow copy device name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy11 > - Originating machine: milano.example.local > - Service machine: milano.example.local > - Not Exposed > - Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5} > - Attributes: No_Auto_Release Persistent Differential > > * SNAPSHOT ID = {fb5996cf-a35b-4110-b83c-45f9c64a75f3} ... > - Shadow copy Set: {427ac5db-21be-4c53-8ca4-24e7bac86a1d} > - Original count of shadow copies = 2 > - Original Volume name: \\?\Volume{787bdf7b-ccff-11dd-9866-806e6f6e6963}\ [E:\] > - Creation Time: 6/10/2009 12:12:08 PM > - Shadow copy device name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy12 > - Originating machine: milano.example.local > - Service machine: milano.example.local > - Not Exposed > - Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5} > - Attributes: No_Auto_Release Persistent Differential > > My current script only uses sed/grep but I never had to deal with this case > where now I need to do something based on the grep'ed/sed extraction of the > value of "SNAPSHOT ID" based on volume name "D:" or "E:"? To make my script > work without rewriting it, is there a sed method to only take the "SNAPSHOT ID" > if the text indented beneath it has "D:", then do the same and extract > "SNAPSHOT ID" if and only if "E:" follows?Are the volume IDs in just two groups? E.g. all "C:", then all "D:", "E:', ...? If so, use of the csplit command as a precursor to the sed should really shorten the learning curve and be more robust against any unexpected format changes. If that doesn't look feasible or desirable, post a small snippt as an example and I'll see what I can do. Others will suggest perl and (g)awk, etc. Both can be good solutions, depending. If the csplit wil work within your design, it would probably be easier due to the utility nature and very small learning curve. "Man csplit".> > Thanks for any help! > jlc > <snip sig stuff>HTH -- Bill
Joseph L. Casale wrote:> if the text indented beneath it has "D:", then do the same and extract > "SNAPSHOT ID" if and only if "E:" follows?If the line counts are constant you could do the reverse: grep -B 3 "\(E:\|D:\)" input.txt | grep Shadow Which would show the 3 lines above a line that has E:\ or D:\ and then only display the lines with the word Shadow. nate
On Jun 10, 2009, at 2:18 PM, Joseph L. Casale wrote:> I am rsyncing and remotely doing some work based on a logfile from > a windows box from a centos backup server. I get the output from a > vss snapshot that has a section like this: > > * SNAPSHOT ID = {639ef5df-c933-4496-878a-ed57b9d52876} ... > - Shadow copy Set: {427ac5db-21be-4c53-8ca4-24e7bac86a1d} > - Original count of shadow copies = 2 > - Original Volume name: \\?\Volume{787bdf7a- > ccff-11dd-9866-806e6f6e6963}\ [D:\] > - Creation Time: 6/10/2009 12:12:08 PM > - Shadow copy device name: \\?\GLOBALROOT\Device > \HarddiskVolumeShadowCopy11 > - Originating machine: milano.example.local > - Service machine: milano.example.local > - Not Exposed > - Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5} > - Attributes: No_Auto_Release Persistent Differential > > * SNAPSHOT ID = {fb5996cf-a35b-4110-b83c-45f9c64a75f3} ... > - Shadow copy Set: {427ac5db-21be-4c53-8ca4-24e7bac86a1d} > - Original count of shadow copies = 2 > - Original Volume name: \\?\Volume{787bdf7b- > ccff-11dd-9866-806e6f6e6963}\ [E:\] > - Creation Time: 6/10/2009 12:12:08 PM > - Shadow copy device name: \\?\GLOBALROOT\Device > \HarddiskVolumeShadowCopy12 > - Originating machine: milano.example.local > - Service machine: milano.example.local > - Not Exposed > - Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5} > - Attributes: No_Auto_Release Persistent Differential > > My current script only uses sed/grep but I never had to deal with > this case > where now I need to do something based on the grep'ed/sed extraction > of the > value of "SNAPSHOT ID" based on volume name "D:" or "E:"? To make my > script > work without rewriting it, is there a sed method to only take the > "SNAPSHOT ID" > if the text indented beneath it has "D:", then do the same and extract > "SNAPSHOT ID" if and only if "E:" follows? > > Thanks for any help! > jlcYou could also use awk and set the record separator RS to "\n\n" and the field separator to "\n". Then each record consists of 11 fields consisting of each line. Tony Schreiner
Maybe Matching Threads
- Re: C&C Red Alert 3 - Lan (and also hamachi) play
- how to use {6FDE7547-1B65-48ae-B628-80BE62016026}\VIOSerialPort ?
- Concurrent scanning of same disk
- USB-hotplugging fails with "failed to load cgroup BPF prog: Operation not permitted" on cgroups v2
- Expected error with help.search in R 3.2.0