如何在不添加行的情况下添加到SED的末尾



我正在尝试使用sed向2200万行添加一个插入行。我目前的命令是:;

sed -i 's/ //g' test.txt (Removes any spaces)
sed -i ':;N;$!b;s/n/");n/g' test.txt (Adds "); to end of line)
sed -i -e "s/^/INSERT INTO TABLES (FIELD) VALUES ("/" test.txt (Adds insert with (")

如果我在10行的测试中运行它,它会很好,每当我在2200万行的主txt文件中运行它时,它都会像…一样运行

INSERT INTO TABLE (FIELD) VALUES ("123456
")
INSERT INTO TABLE (FIELD) VALUES ("567891011
")

这导致在编号之后添加"

我试图将其作为INSERT INTO TABLE(FIELD)VALUES("567891011")实现

这还不够吗

sed 's/s*//g' test.txt
sed 's/$/");/' test.txt
sed 's/^.+$/INSERT INTO TABLES (FIELD) VALUES ("/' text.txt

或者你可以把它作为放在一行

sed 's/s*//g; s/^.+$/INSERT INTO TABLES (FIELD) VALUES ("");/' test.txt

最新更新