を使用した1つのソリューションsed
。-- Dumping data for table 'big_table'
リテラルと。の間のすべての行を検索します-- Table structure for table
。そして、で始まらない行にコメントし--
ます。
の内容を想定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
コマンドを実行します:
sed -e '
/-- Dumping data for table `big_table`/,/-- Table structure for table/ {
/^--/! s/^/--/
}
' 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