У меня есть это жало: the string's problem, и я хочу изменить это на:
file 'the string'\''s problem'
Мой код выглядит так:
newline=`echo "$string" | sed "s/'/'\\\''/g"`
echo $newline | sed "s|$newline|file '$newline'|g" >> "$newPList"
Но результат этого is:
file 'the string'''s problem'
Любые предложения?
Это perl однострочный, все в одном, без дополнительных строковых конструкций;)
$ perl -pe "s/^(.*)'(.*)$/file '\$1\'\\\'\'\$2'/" <<< "the string's problem"
file 'the string'\''s problem'