One solution using sed . It searches for all rows between literals -- Dumping data for table 'big_table' and -- Table structure for table . And comment on those lines that do not begin with -- .
Assuming the contents of infile :
1 2 3 4 -- -- Dumping data for table `big_table` -- INSERT INTO `big_table` ... INSERT INTO `big_table` ... -- -- Table structure for table `next_table` -- 1 2 3 4 5 6
Launch command:
sed -e ' /-- Dumping data for table `big_table`/,/-- Table structure for table/ { /^--/! s/^/--/ } ' infile
With the following output:
1 2 3 4 -- -- Dumping data for table `big_table` -- -- --INSERT INTO `big_table` ... --INSERT INTO `big_table` ... -- -- -- -- Table structure for table `next_table` -- 1 2 3 4 5 6
Birei source share