1

如何在搜索字符串后准确删除 1 个单词?我可以删除搜索词,但不能删除之后的词,即“utf8”

# echo "varchar(255) CHARACTER SET utf8,"
varchar(255) CHARACTER SET utf8,

# echo "varchar(255) CHARACTER SET utf8," |  sed 's/ CHARACTER SET[^ ]* / /g'
varchar(255) utf8,

预期输出:

varchar(255) ,
4

4 回答 4

2
echo "varchar(255) CHARACTER SET utf8," |  sed 's/ CHARACTER SET [[:alnum:]]\+/ /g'
于 2012-10-25T07:15:52.487 回答
1

你是这个意思吗?

echo "varchar(255) CHARACTER SET utf8," |  sed 's/ CHARACTER SET[ a-z0-9,]*/ /g'

输出

varchar(255)
于 2012-10-25T07:19:30.237 回答
1

这可能对您有用(GNU sed):

echo "varchar(255) CHARACTER SET utf8," |  sed 's/ CHARACTER SET \w*/ /g'
于 2012-10-25T07:20:45.993 回答
0

echo "varchar(255) 字符集 utf8, aa" | sed 's/ 字符集.*,/ /g'

于 2013-01-29T04:52:45.450 回答