Back To Blog Posts
Using SED to replace urls in a list of files
Say you have a list of files on your harddrive and you want to replace
/api/hello.json
with
/api/v2/hello.json
This can be done very easily with sed
:
for f in ./swagger/v2/api/v2/*.json; do
echo $f
sed -i -e s/api\\//api\\/v2\\// $f
done
This command will overwrite your files and replace that URL.