I'm looking for a way to replace all the occurrences of a website in a file with a constant. I'm using gsed and regex on my mac (don't get deviated with the term mac, as this is the same output I'm getting even when executing on a windows machine) to accomplish this. I'm able to successfully validate the regex on regex101.com but sed substitution is failing for some reason
gsed --version : gsed (GNU sed) 4.8
(g)sed command:
find . -type f -path "./file1.txt" -exec gsed -i -E -f /tmp/scripts/regex {} \;
/tmp/scripts/regex contents:
s/(ftp|http[s]?):\/\/([\w\.-]+)/\1{Your_Site}/gI
Sample file1.txt contents:
* "{\n \"firstName\": \"\",\n \"lastName\": \"\",\n \"street1\": \"\",\n \"street2\": \"\",\n \"city\": \"\",\n \"state\": \"\",\n \"postalCode\": \"\",\n \"country\": \"\",\n \"domain\": \"http://example.org\",\n \"action\": \"addUser\",\n \"token\": \"\",\n \"transId\": \"1413290890.usr.209883490\",\n \"customerId\": \"145qjk345kl_908jkl.345\",\n \"src_name\": \"Your_Application\",\n \"channel\": \"webpage\",\n \"accountId\": \"0097892hjke6987hiuw.ACNT.hsapou8972rjk\",\n \"system\": \"Your_System\",\n \"originatingSystem_code\": \"Your_System_Id\",\n \"purchase_currency\": \"USD\",\n \"url\": \"https://another-link-to-my-example.org/add-user/new\",\n \"createFlag\": \"on\",\n \"web_version\": \"7\",\n
Expected output:
* "{\n \"firstName\": \"\",\n \"lastName\": \"\",\n \"street1\": \"\",\n \"street2\": \"\",\n \"city\": \"\",\n \"state\": \"\",\n \"postalCode\": \"\",\n \"country\": \"\",\n \"domain\": \"http://{Your_Site}\",\n \"action\": \"addUser\",\n \"token\": \"\",\n \"transId\": \"1413290890.usr.209883490\",\n \"customerId\": \"145qjk345kl_908jkl.345\",\n \"src_name\": \"Your_Application\",\n \"channel\": \"webpage\",\n \"accountId\": \"0097892hjke6987hiuw.ACNT.hsapou8972rjk\",\n \"system\": \"Your_System\",\n \"originatingSystem_code\": \"Your_System_Id\",\n \"purchase_currency\": \"USD\",\n \"url\": \"https://{Your_Site}/add-user/new\",\n \"createFlag\": \"on\",\n \"web_version\": \"7\",\n
Current output:
* "{\n \"firstName\": \"\",\n \"lastName\": \"\",\n \"street1\": \"\",\n \"street2\": \"\",\n \"city\": \"\",\n \"state\": \"\",\n \"postalCode\": \"\",\n \"country\": \"\",\n \"domain\": \"http://{Your_Site}xample.org\",\n \"action\": \"addUser\",\n \"token\": \"\",\n \"transId\": \"1413290890.usr.209883490\",\n \"customerId\": \"145qjk345kl_908jkl.345\",\n \"src_name\": \"Your_Application\",\n \"channel\": \"webpage\",\n \"accountId\": \"0097892hjke6987hiuw.ACNT.hsapou8972rjk\",\n \"system\": \"Your_System\",\n \"originatingSystem_code\": \"Your_System_Id\",\n \"purchase_currency\": \"USD\",\n \"url\": \"https://another-link-to-my-example.org/add-user/new\",\n \"createFlag\": \"on\",\n \"web_version\": \"7\",\n
Please ask for any additional info if I might have missed.