bash - sed -i with quotes as first arg -



bash - sed -i with quotes as first arg -

using sed prepare whitespace in git pre-commit hook, ran problems line: sed -i '' [the regex] [the file]

similar comments others mention inconsistency, , taking out quotes fixes problem. confuses me because thought sed -i should take filename parameter next flag. may shell inconsistency; gist linked .sh script , i'm using bash/centos.

what magic/issue behind sed -i '' usage, , how stripping out '' right problem?

as @avinashraj mentioned in comment bsd sed requires argument -i whereas gnu sed makes argument optional (and doesn't allow space in quick test on centos 5).

because of gnu sed behaviour using sed -i '' 'script' file going fail because assume -i has no argument, utilize '' script run, , utilize 'script' first file operate on.

using sed -i '' -e 'script' file solve script-as-filename problem gnu sed leaves interpreting '' filename.

using sed -i'' -e 'script' file solves that problem.

i have no thought whether legal bsd sed though. expect -e 'script' fine.

the question whether accepts suffix smushed against -i flag.

edit: @charlesduffy accurately points out bsd sed cannot perchance take -i'' or take -i since cannot tell difference between in argument processing (the empty string has dropped away @ point).

which means, unless i've missed or gnu sed can take -i '' correctly don't see way portably.

bash shell sed

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -