1
Looking for some help on this task. I have tried several shell scripts to do this, but not sure I am approaching this problem right. I have a file that contains several blocks of data like this:
multipath {
wwid 360000970000195701574533030394530
alias DG_cln_DRPCU04_Oberon_IX_disk59
}
multipath {
wwid 360000970000195701574533030394531
alias DG_cln_DRPCU04_Oberon_IX_disk60
}
multipath {
wwid 360000970000195701574533030394532
alias DG_cln_DRPCU04_Oberon_IX_disk61
}
multipath {
wwid 360000970000195701574533030394533
alias DG_cln_DRPCU04_Oberon_IX_disk62
}
multipath {
wwid 360000970000195701574533030394534
alias DG_cln_DRPCU04_Oberon_IX_disk63
}
multipath {
wwid 360000970000195701574533030394535
alias DG_cln_DRPCU04_Oberon_IX_disk6
}
multipath {
wwid 360000970000195701574533030394536
alias DG_cln_DRPCU04_Oberon_IX_disk64
}
I want to comment out only specific blocks. I want to change only the lines in the block that I have greped for.
Example:
grep -B 2 -A 1 DG_cln_DRPCU04_Oberon.
It would return every block that contains DG_cln_DRPCU04_Oberon. I then want to comment out that entire block of 4 lines, for each unique block that is returned. Is there an easy way to do this? Thanks for any pointers of suggestions on how to approach this problem.
So when you use grep just add
-n
options to get the line number after this you can get line number which you need to comment out. So you can use this number insed
to change it to/*blabla*/
. I think this approach will help you – makgun – 2016-06-09T21:44:08.977