cat file.txt | perl -pe 's/\"[^[\'\`]/"`/g' #### $ perl -pe "s/\"([^'\`])/'\$1/g" This is "an example", but "`this not"'. This is 'an example', but "`this not"'.