I have a requirement to change the contents of config.tsx file that contains values like:
JavaScript
x
const authData = {
base_uri: 'https://development-api.com.au',
customLib: {
redirect_uri: 'https://another-development-api.com.au'
}
}
export default authData;
I want to change this content using a shell script and save the file. Changed content can look like:
JavaScript
const authData = {
base_uri: 'https://production-api.com.au',
customLib: {
redirect_uri: 'https://another-production-api.com.au'
}
}
export default authData;
How can I do this?
Advertisement
Answer
This should work:
JavaScript
sed -i 's/development/production/g' config.tsx
The -i
option will edit the file in place. If you first want to try the command to see if it works the way you want, use it without the -i
. The output will be printed to stdout.