我需要一个内联 sed 命令将“string”替换为“varchar(30)”,但是创建表语法可以位于多行。
有没有办法告诉 sed (或使用 awk?)在不以“INSERT INTO...”开头的行上进行替换?
“字符串”一词可能出现在我的数据中,我不希望数据损坏。
sed -i 's/string/varchar(30)/g'
我知道基本的正则表达式,但这超出了我的能力范围。谢谢!
最佳答案
sed -i '/^INSERT INTO/! s/string/varchar(30)/g'
来自sed man page :
After the address (or address-range), and before the command, a
!
may be inserted, which specifies that the command shall only be executed if the address (or address-range) does not match.
关于mysql - Linux SED AWK Sqlite 转储到 MySQL 将以 create table 开头的行上的字符串更改为 varchar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22179335/