Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
输入文件就像
<org.eclipse.core.runtime.adaptor.EclipseClassLoader@1c7d9114,Lorg/eclipse/core/ resources/ResourcesPlugin;>.<init>(Lorg/eclipse/core/runtime/IPluginDescriptor;)V
目标是删除像1c7d9114,.
1c7d9114,
十六进制字符串的长度是固定的,即 8。
还请包括紧随其后的逗号。
有没有什么简单的脚本可以解决这个问题?
使用sed:
sed 's/@[a-f0-9]\{8\},/@/' input
使用perl:
perl -pe 's/\@[a-f0-9]{8},/\@/' input.txt
使用awk:
awk '{gsub(/@[a-f0-9]{8},/,"@",$0)}1' input.txt