我正在寻找仅使用bash /标准Linux命令即可将字符串转换为以下内容的东西:
例如:
Thank you!
应该这样做:
sed "s/^\([\"']\)\(.*\)\1\$/\2/g" in.txt
其中in.txt是:
"Fo'od' 'Food' "Food" "Fo"od' Food 'Food" "Food' 'Fo'od' "Fo'od" Fo'od 'Fo"od' "Fo"od" Fo"od
而Expected.txt是:
"Fo'od' Food Food "Fo"od' Food 'Food" "Food' Fo'od Fo'od Fo'od Fo"od Fo"od Fo"od
您可以检查它们是否符合:
diff -s <(sed "s/^\([\"']\)\(.*\)\1\$/\2/g" in.txt) expected.txt