kevdog
January 9th, 2016, 05:19 PM
I'm not a sed expert but definitely not a beginner.
I've broken down my problem and I quite quite figure out why I can't match the expression #!/usr/bin/python. I'm trying to replace all occurrences of #!/usr/bin/python with #!/usr/bin/python2
Here is my simplified example:
sed -ri "s|^#!/usr/bin/python$|&2|g" setup.py
It returns:
bash: !/usr/bin/python$: event not found
It's not found because it's not matching the # symbol
If I use the expression:
sed -ri "s|#!/usr/bin/python$|&2|g" setup.py
Things work as expected, however I want to match the beginning of the line.
I'm confused what to do at this point.
I've broken down my problem and I quite quite figure out why I can't match the expression #!/usr/bin/python. I'm trying to replace all occurrences of #!/usr/bin/python with #!/usr/bin/python2
Here is my simplified example:
sed -ri "s|^#!/usr/bin/python$|&2|g" setup.py
It returns:
bash: !/usr/bin/python$: event not found
It's not found because it's not matching the # symbol
If I use the expression:
sed -ri "s|#!/usr/bin/python$|&2|g" setup.py
Things work as expected, however I want to match the beginning of the line.
I'm confused what to do at this point.