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.
  • 46,058
  • 19
  • 106
  • 116

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
  • 22,354
  • 4
  • 21
  • 46