0

I want to use a sed command in as script to change the Ansible version in a file from '2.7' to 2.9 and keep the single quotes, '.

This is what I use, but it seems like the result does not have the single quotes:

sed -i 's/^ansible::version:.*/ansible::version:'$vers'/' /path_to_file

output:

ansible::version: 2.9

This is the content of the file:

ansible::version: '2.7'
Benjamin W.
  • 38,596
  • 16
  • 96
  • 104

1 Answers1

0

BSD sed: sed "s/'2\.7'/'2\.9'/g" file & GNU sed: sed "s/'2\.7'/'2\.9'/g" file

jared_mamrot
  • 14,156
  • 3
  • 17
  • 38