0

I have a Podspec and I want to change the version in that file using sed and regex. the line is below

s.version  (ignore spaces)  =  (ignore spaces) "x.x.x"

What would be the exact sed command to change this version.

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
g.revolution
  • 11,962
  • 23
  • 81
  • 107
  • possible duplicate of [Sed command find and replace in file and overwrite file doesnt work, it empties the file](http://stackoverflow.com/questions/5171901/sed-command-find-and-replace-in-file-and-overwrite-file-doesnt-work-it-empties) – tripleee Dec 10 '14 at 12:01
  • This question is extremely common. What have you tried? How did it fail? Which part are you having trouble with? – tripleee Dec 10 '14 at 12:02
  • the regex part. see the answer – g.revolution Dec 10 '14 at 12:03

1 Answers1

2

Simply use

~$ sed 's/^\(s.version *= *\)"[^"]*"/\1"a.b.c"/' myfile

You can use the -i option to modify in place the file.

fredtantini
  • 15,966
  • 8
  • 49
  • 55
  • i changed it like this : sed 's/^\(*s.version *= *\)"[^"]*"/\1"a.b.c"/' myfile to ignore spaces in the start too. thanks for your answer. it works. – g.revolution Dec 10 '14 at 12:07