我在一个文件夹中有许多这样的脚本:
INSERT INTO fv_xml_binary_adim VALUES (1, '<FeatureVector><feature>project</feature><feature>w</feature><feature>focus</feature><feature>d</feature><feature>new</feature><feature>cut</feature><feature>tool</feature><feature>design</feature><feature>allow</feature><feature>increas</feature><feature>high</feature><feature>speed</feature><feature>machin</feature><feature>hsm</feature><feature>product</feature></FeatureVector>');
我想把一个字符的元素转换成两个字符的元素。我想把上面的命令转换成:
INSERT INTO fv_xml_binary_adim VALUES (1, '<FeatureVector><feature>project</feature><feature>w0</feature><feature>focus</feature><feature>d0</feature><feature>new</feature><feature>cut</feature><feature>tool</feature><feature>design</feature><feature>allow</feature><feature>increas</feature><feature>high</feature><feature>speed</feature><feature>machin</feature><feature>hsm</feature><feature>product</feature></FeatureVector>');
如何使用sed或其他bash文本处理命令实现它?
3条答案
按热度按时间thtygnil1#
与
sed
```$ sed -E 's/>(.)</>\10</g' file
bsxbgnwa2#
与
sed
您可以使用:这将改变
>w<
进入>w0<
等等。cgfeq70w3#
您可以尝试将regex与sed一起使用
sed -i -E "s%(feature>)([a-z]{1})(</feature)%\1\20\3%g" file