简体   繁体   中英

how to use sed to replace a line in a file

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.

Simply use

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM