complicated command replace in files using sed
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I want to replace the below strings
replace: print 'Status Code: code'.format(code=r.status_code)
with: print('Status Code: code'.format(code=r.status_code))
Here is the command I ran which fails
find ./ -type f -exec gsed 's/'print 'Status Code: code'.format(code=r.status_code)'/'print('Status Code: code'.format(code=r.status_code))'/g' ;
I tried to use to avoid the special characters effect but still fails too and just hangs.
find ./ -type f -exec gsed -i 's/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/g' ;
>
>
>
linux sed find string
add a comment |
up vote
0
down vote
favorite
I want to replace the below strings
replace: print 'Status Code: code'.format(code=r.status_code)
with: print('Status Code: code'.format(code=r.status_code))
Here is the command I ran which fails
find ./ -type f -exec gsed 's/'print 'Status Code: code'.format(code=r.status_code)'/'print('Status Code: code'.format(code=r.status_code))'/g' ;
I tried to use to avoid the special characters effect but still fails too and just hangs.
find ./ -type f -exec gsed -i 's/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/g' ;
>
>
>
linux sed find string
(Please do NOT close and mark this as duplicate by simply referencing a generic sed or perl question, I've spent more than a few hours trying to research this on stackExchange and web without any hopes )
– nanoseconds
1 hour ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to replace the below strings
replace: print 'Status Code: code'.format(code=r.status_code)
with: print('Status Code: code'.format(code=r.status_code))
Here is the command I ran which fails
find ./ -type f -exec gsed 's/'print 'Status Code: code'.format(code=r.status_code)'/'print('Status Code: code'.format(code=r.status_code))'/g' ;
I tried to use to avoid the special characters effect but still fails too and just hangs.
find ./ -type f -exec gsed -i 's/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/g' ;
>
>
>
linux sed find string
I want to replace the below strings
replace: print 'Status Code: code'.format(code=r.status_code)
with: print('Status Code: code'.format(code=r.status_code))
Here is the command I ran which fails
find ./ -type f -exec gsed 's/'print 'Status Code: code'.format(code=r.status_code)'/'print('Status Code: code'.format(code=r.status_code))'/g' ;
I tried to use to avoid the special characters effect but still fails too and just hangs.
find ./ -type f -exec gsed -i 's/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/g' ;
>
>
>
linux sed find string
linux sed find string
edited 2 hours ago
Rui F Ribeiro
38k1475123
38k1475123
asked 2 hours ago
nanoseconds
1534
1534
(Please do NOT close and mark this as duplicate by simply referencing a generic sed or perl question, I've spent more than a few hours trying to research this on stackExchange and web without any hopes )
– nanoseconds
1 hour ago
add a comment |
(Please do NOT close and mark this as duplicate by simply referencing a generic sed or perl question, I've spent more than a few hours trying to research this on stackExchange and web without any hopes )
– nanoseconds
1 hour ago
(Please do NOT close and mark this as duplicate by simply referencing a generic sed or perl question, I've spent more than a few hours trying to research this on stackExchange and web without any hopes )
– nanoseconds
1 hour ago
(Please do NOT close and mark this as duplicate by simply referencing a generic sed or perl question, I've spent more than a few hours trying to research this on stackExchange and web without any hopes )
– nanoseconds
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can either use double quotes around the expression, or close and re-open the single quotes around each literal '
, like '''
:
sed "s/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/"
sed 's/print '''Status Code: code'''.format(code=r.status_code)/print('''Status Code: code'''.format(code=r.status_code))/'
@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can either use double quotes around the expression, or close and re-open the single quotes around each literal '
, like '''
:
sed "s/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/"
sed 's/print '''Status Code: code'''.format(code=r.status_code)/print('''Status Code: code'''.format(code=r.status_code))/'
@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago
add a comment |
up vote
1
down vote
accepted
You can either use double quotes around the expression, or close and re-open the single quotes around each literal '
, like '''
:
sed "s/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/"
sed 's/print '''Status Code: code'''.format(code=r.status_code)/print('''Status Code: code'''.format(code=r.status_code))/'
@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can either use double quotes around the expression, or close and re-open the single quotes around each literal '
, like '''
:
sed "s/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/"
sed 's/print '''Status Code: code'''.format(code=r.status_code)/print('''Status Code: code'''.format(code=r.status_code))/'
You can either use double quotes around the expression, or close and re-open the single quotes around each literal '
, like '''
:
sed "s/print 'Status Code: code'.format(code=r.status_code)/print('Status Code: code'.format(code=r.status_code))/"
sed 's/print '''Status Code: code'''.format(code=r.status_code)/print('''Status Code: code'''.format(code=r.status_code))/'
answered 1 hour ago
steeldriver
33.5k34982
33.5k34982
@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago
add a comment |
@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago
@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago
@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago
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%2f481035%2fcomplicated-command-replace-in-files-using-sed%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
(Please do NOT close and mark this as duplicate by simply referencing a generic sed or perl question, I've spent more than a few hours trying to research this on stackExchange and web without any hopes )
– nanoseconds
1 hour ago