sed - Append Line Bash File -


one liner in bash (for example using sed) append line before last line in file.

example

old file

foo bar foo bar foo bar foo bar 

new file

foo bar foo bar foo bar --new foo bar foo bar 

i tried sed on osx that

sed '$ --new foo bar' file.sh 

i error command expects \ followed text. ideas?

while versions of sed (e.g. gnu sed) support i command on same line text inserted, posix standard specifies usage this:

sed '$i\ --new foo bar' file.sh 

that is, i followed backslash , newline, text inserted.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -