输入示例:
[email protected] [email protected],[email protected]
示例输出:
[email protected] [email protected],[email protected]
因此,在“正常”情况下,显然很容易执行以下操作:
sed 's/.com/.org/g'
但是显然在这种情况下,我只希望操纵第一列中的后缀,而不希望改变第二列。
我不介意您建议使用哪种工具。但我更喜欢它在标准linux上可用而无需进一步安装(即,类似sed
或awk
或perl
会更可取bobsobscuretoolthatneedsinstalling
)。
$ awk '{ sub("\.com$", ".org", $1); print }' <file
[email protected] [email protected],[email protected]
这用于awk
替换每行的第一个以空格分隔的字段中(\.com$
与)匹配的文本.org
。输出将以空格分隔。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句