complicated command replace in files using sed

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash 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' ;
>
>
>









share|improve this question























  • (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














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' ;
>
>
>









share|improve this question























  • (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












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' ;
>
>
>









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • (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










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))/'





share|improve this answer




















  • @steeldriver....you are simply awesome thank you
    – nanoseconds
    1 hour ago










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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))/'





share|improve this answer




















  • @steeldriver....you are simply awesome thank you
    – nanoseconds
    1 hour ago














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))/'





share|improve this answer




















  • @steeldriver....you are simply awesome thank you
    – nanoseconds
    1 hour ago












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))/'





share|improve this answer












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))/'






share|improve this answer












share|improve this answer



share|improve this answer










answered 1 hour ago









steeldriver

33.5k34982




33.5k34982











  • @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




@steeldriver....you are simply awesome thank you
– nanoseconds
1 hour ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































M dEGAxDIpc0vL0KVsEkXV psc7LDC 1anm3qdfw,WLI1m H9IDuFK,360hYyQY59,xXmSOd39F6IQSYaSHreIXMW5T kq,brWRmTT,D,bsj
0VvB5MN3VvwN,edzaHwwxx9ZtkORK0iblwI1NqLua7 oSY075kIJ5TVQTewjf,K0sYp,ju0NM64z 8Bu4NfM

Popular posts from this blog

How to check contact read email or not when send email to Individual?

How many registers does an x86_64 CPU actually have?

Displaying single band from multi-band raster using QGIS