如何在搜索字符串后删除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) ,
答案 0 :(得分:2)
echo "varchar(255) CHARACTER SET utf8," | sed 's/ CHARACTER SET [[:alnum:]]\+/ /g'
答案 1 :(得分:1)
你的意思是?
echo "varchar(255) CHARACTER SET utf8," | sed 's/ CHARACTER SET[ a-z0-9,]*/ /g'
输出
varchar(255)
答案 2 :(得分:1)
这可能适合你(GNU sed):
echo "varchar(255) CHARACTER SET utf8," | sed 's/ CHARACTER SET \w*/ /g'
答案 3 :(得分:0)
echo“varchar(255)CHARACTER SET utf8,aa”| sed's / CHARACTER SET。*,/ / g'