Search and replace substring with an other in all the files of a folder and all its subfolders

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I know there are several questions as this one, but mine is specific:
I want to replace the substring: localhost:8000/ with https://www.begueradj.com/ in all the HTML files existing in a folder and its sub folders.
The / and // are causing me problems in this situation.
Any hints?
Edit:
The attempt I tried to work more on is the one described here.
But any other effective approach is welcome.
string replace
add a comment |Â
up vote
1
down vote
favorite
I know there are several questions as this one, but mine is specific:
I want to replace the substring: localhost:8000/ with https://www.begueradj.com/ in all the HTML files existing in a folder and its sub folders.
The / and // are causing me problems in this situation.
Any hints?
Edit:
The attempt I tried to work more on is the one described here.
But any other effective approach is welcome.
string replace
Could you please elaborate on your approach (sed,find, etcetera)?
â maulinglawns
Feb 1 at 19:36
All you need to do is use different delimters for the seds///command: for examples@http://localhost:8000/@https://www.begueradj.com/@
â glenn jackman
Feb 1 at 19:55
Also, I see you have fancy curly quotes for the sed body. Take care to use simple plain quotes there.
â glenn jackman
Feb 1 at 19:56
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I know there are several questions as this one, but mine is specific:
I want to replace the substring: localhost:8000/ with https://www.begueradj.com/ in all the HTML files existing in a folder and its sub folders.
The / and // are causing me problems in this situation.
Any hints?
Edit:
The attempt I tried to work more on is the one described here.
But any other effective approach is welcome.
string replace
I know there are several questions as this one, but mine is specific:
I want to replace the substring: localhost:8000/ with https://www.begueradj.com/ in all the HTML files existing in a folder and its sub folders.
The / and // are causing me problems in this situation.
Any hints?
Edit:
The attempt I tried to work more on is the one described here.
But any other effective approach is welcome.
string replace
edited Feb 5 at 16:12
asked Feb 1 at 19:27
Billal BEGUERADJ
1901210
1901210
Could you please elaborate on your approach (sed,find, etcetera)?
â maulinglawns
Feb 1 at 19:36
All you need to do is use different delimters for the seds///command: for examples@http://localhost:8000/@https://www.begueradj.com/@
â glenn jackman
Feb 1 at 19:55
Also, I see you have fancy curly quotes for the sed body. Take care to use simple plain quotes there.
â glenn jackman
Feb 1 at 19:56
add a comment |Â
Could you please elaborate on your approach (sed,find, etcetera)?
â maulinglawns
Feb 1 at 19:36
All you need to do is use different delimters for the seds///command: for examples@http://localhost:8000/@https://www.begueradj.com/@
â glenn jackman
Feb 1 at 19:55
Also, I see you have fancy curly quotes for the sed body. Take care to use simple plain quotes there.
â glenn jackman
Feb 1 at 19:56
Could you please elaborate on your approach (
sed, find, etcetera)?â maulinglawns
Feb 1 at 19:36
Could you please elaborate on your approach (
sed, find, etcetera)?â maulinglawns
Feb 1 at 19:36
All you need to do is use different delimters for the sed
s/// command: for examples@http://localhost:8000/@https://www.begueradj.com/@â glenn jackman
Feb 1 at 19:55
All you need to do is use different delimters for the sed
s/// command: for examples@http://localhost:8000/@https://www.begueradj.com/@â glenn jackman
Feb 1 at 19:55
Also, I see you have fancy curly quotes for the sed body. Take care to use simple plain quotes there.
â glenn jackman
Feb 1 at 19:56
Also, I see you have fancy curly quotes for the sed body. Take care to use simple plain quotes there.
â glenn jackman
Feb 1 at 19:56
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
There are (at least) two things to improve here:
- using
foron a list of file names generated by another command tends to break in rather interesting ways if file names contain space characters or worse - the quotes you use in
sedare odd
Try
find . -name '*.html' -print0 |
xargs -0 sed -i 's|localhost:8000|https://www.begueradj.com/|'
The -print0 option of find will make sure that all names passed to xargs are NUL-terminated.
Thank you. But I am getting this :sed: no input files
â Billal BEGUERADJ
Feb 1 at 20:04
@BillalBEGUERADJ Ups, sorry, try again
â nohillside
Feb 1 at 20:05
@BillalBEGUERADJ If it still doesn't work: Doesfind . -name '*.html' -printreturn anything? If not your HTML files don't end in.html.
â nohillside
Feb 1 at 20:06
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
There are (at least) two things to improve here:
- using
foron a list of file names generated by another command tends to break in rather interesting ways if file names contain space characters or worse - the quotes you use in
sedare odd
Try
find . -name '*.html' -print0 |
xargs -0 sed -i 's|localhost:8000|https://www.begueradj.com/|'
The -print0 option of find will make sure that all names passed to xargs are NUL-terminated.
Thank you. But I am getting this :sed: no input files
â Billal BEGUERADJ
Feb 1 at 20:04
@BillalBEGUERADJ Ups, sorry, try again
â nohillside
Feb 1 at 20:05
@BillalBEGUERADJ If it still doesn't work: Doesfind . -name '*.html' -printreturn anything? If not your HTML files don't end in.html.
â nohillside
Feb 1 at 20:06
add a comment |Â
up vote
2
down vote
accepted
There are (at least) two things to improve here:
- using
foron a list of file names generated by another command tends to break in rather interesting ways if file names contain space characters or worse - the quotes you use in
sedare odd
Try
find . -name '*.html' -print0 |
xargs -0 sed -i 's|localhost:8000|https://www.begueradj.com/|'
The -print0 option of find will make sure that all names passed to xargs are NUL-terminated.
Thank you. But I am getting this :sed: no input files
â Billal BEGUERADJ
Feb 1 at 20:04
@BillalBEGUERADJ Ups, sorry, try again
â nohillside
Feb 1 at 20:05
@BillalBEGUERADJ If it still doesn't work: Doesfind . -name '*.html' -printreturn anything? If not your HTML files don't end in.html.
â nohillside
Feb 1 at 20:06
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
There are (at least) two things to improve here:
- using
foron a list of file names generated by another command tends to break in rather interesting ways if file names contain space characters or worse - the quotes you use in
sedare odd
Try
find . -name '*.html' -print0 |
xargs -0 sed -i 's|localhost:8000|https://www.begueradj.com/|'
The -print0 option of find will make sure that all names passed to xargs are NUL-terminated.
There are (at least) two things to improve here:
- using
foron a list of file names generated by another command tends to break in rather interesting ways if file names contain space characters or worse - the quotes you use in
sedare odd
Try
find . -name '*.html' -print0 |
xargs -0 sed -i 's|localhost:8000|https://www.begueradj.com/|'
The -print0 option of find will make sure that all names passed to xargs are NUL-terminated.
edited Feb 1 at 22:23
answered Feb 1 at 20:01
nohillside
1,868616
1,868616
Thank you. But I am getting this :sed: no input files
â Billal BEGUERADJ
Feb 1 at 20:04
@BillalBEGUERADJ Ups, sorry, try again
â nohillside
Feb 1 at 20:05
@BillalBEGUERADJ If it still doesn't work: Doesfind . -name '*.html' -printreturn anything? If not your HTML files don't end in.html.
â nohillside
Feb 1 at 20:06
add a comment |Â
Thank you. But I am getting this :sed: no input files
â Billal BEGUERADJ
Feb 1 at 20:04
@BillalBEGUERADJ Ups, sorry, try again
â nohillside
Feb 1 at 20:05
@BillalBEGUERADJ If it still doesn't work: Doesfind . -name '*.html' -printreturn anything? If not your HTML files don't end in.html.
â nohillside
Feb 1 at 20:06
Thank you. But I am getting this :
sed: no input files â Billal BEGUERADJ
Feb 1 at 20:04
Thank you. But I am getting this :
sed: no input files â Billal BEGUERADJ
Feb 1 at 20:04
@BillalBEGUERADJ Ups, sorry, try again
â nohillside
Feb 1 at 20:05
@BillalBEGUERADJ Ups, sorry, try again
â nohillside
Feb 1 at 20:05
@BillalBEGUERADJ If it still doesn't work: Does
find . -name '*.html' -print return anything? If not your HTML files don't end in .html.â nohillside
Feb 1 at 20:06
@BillalBEGUERADJ If it still doesn't work: Does
find . -name '*.html' -print return anything? If not your HTML files don't end in .html.â nohillside
Feb 1 at 20:06
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f421276%2fsearch-and-replace-substring-with-an-other-in-all-the-files-of-a-folder-and-all%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Could you please elaborate on your approach (
sed,find, etcetera)?â maulinglawns
Feb 1 at 19:36
All you need to do is use different delimters for the sed
s///command: for examples@http://localhost:8000/@https://www.begueradj.com/@â glenn jackman
Feb 1 at 19:55
Also, I see you have fancy curly quotes for the sed body. Take care to use simple plain quotes there.
â glenn jackman
Feb 1 at 19:56