Это perl однострочный, все в одном, без дополнительных строковых конструкций;)
$ perl -pe "s/^(.*)'(.*)$/file '\$1\'\\\'\'\$2'/" <<< "the string's problem" file 'the string'\''s problem'