I have a basic python script that looks like this:
my_name = 'Zed'
my_age = 35
my_height = 74
my_weight = 180
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'
print "let's talk about %s" % my_name
print "he's %d inches tall" % my_height
print "he's %d pounds heavy" % my_weight
print "actually, that's not too heavy"
print "he's got %s eyes and %s hair" % (my_eyes, my_hair)
print "his teeth are usually %s depending on the coffee" % my_teeth
print "if I add %d, %d, and %d, I'd get %d" %(my_age, my_height, my_weight, my_age + my_height + my_weight)
I wanted to delete all of the instances of "my_
" in this file so I ran the sed
command:
sed 's/my_//' pythonscript.py > altered_mypythonscript.py
The outputs deleted all of the instances of "my_
" everywhere except for the line at the end of the script right here:
print "if I add %d, %d, and %d, I'd get %d" %(my_age, my_height, my_weight, my_age + my_height + my_weight)
Why is sed
not replacing the words in the parenthesis I want it to, and how can I fix this? Maybe my google abilities have failed me, but I haven't read anything about sed
's substitute command being affected by parenthesis. I could be wrong though.