Skip to main content
Post Closed as "Duplicate" by don_crissti, Thomas, RalfFriedl, Chris Davies, elbarna
edited tags
Link
don_crissti
  • 85.7k
  • 31
  • 234
  • 262
please keep it short and on topic. multiple begging is not nice
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

Need your help, I have looked all over the stackexchange and spent hours over this simple replacement string problem but I've had no luck. I simply 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' {} \;
> 
> 
> 

I have exhausted my search options on stackoverflow/StackExchange and web and I need your help to solve this problem.

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

Need your help, I have looked all over the stackexchange and spent hours over this simple replacement string problem but I've had no luck. I simply 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' {} \;
> 
> 
> 

I have exhausted my search options on stackoverflow/StackExchange and web and I need your help to solve this problem.

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

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' {} \;
> 
> 
> 
Source Link
grepit
  • 213
  • 2
  • 6

complicated command replace in files using sed

Need your help, I have looked all over the stackexchange and spent hours over this simple replacement string problem but I've had no luck. I simply 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' {} \;
> 
> 
> 

I have exhausted my search options on stackoverflow/StackExchange and web and I need your help to solve this problem.

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