sed: Replacing variableURLs in a file for iOS

sed -i "s/"${LOCALHOST_ADDRESS}"/${APIGATEWAY_ADDRESS}/g" path/to/my/file

Error out with:

sed: 1: “path/to/my/file …“: command i expects \ followed by text

To fix it I had to use

sed -i '' "s~${LOCALHOST_ADDRESS}~${APIGATEWAY_ADDRESS}~g" path/to/my/file
  • ‘’ the single quotes after -i which are required for the iOS
  • ~ which is required to escape the // in the URL addresses

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Edgar Sanchez

Edgar Sanchez

10 Followers

A great architect - humble in spirit. dangerous with production access.