osx - issues with sed on Mountain Lion -


i trying delete line on file looks this:

test 1800 in cname mydomain.com.

i using sed on mountain lion , trying following keep getting no errors, line not deleted.

sed -i -e '/$regex/d' $file 

or

sed -i "" -e '/$regex/d' $file 

where $regex expression containing line mention above , $file name of file line is.

any appreciate it.

this near duplicate of sed command find , replace in file ..., , portable answer same there:

sed -e '/$regex/d' $file >$file.tmp && mv $file.tmp $file 

...for reasons, , advantages, given there. when you're concerned portability, posix spec great resource, since describes common subset of unix commands, frustratingly restricted, pretty reliably present in unixes 1 come across.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -