Append a new line with sed
I've write before about how much I like Perl ... well, related with Perl and command line you got sed wich is:
Ed is a line-oriented text editor, used to create, display, and modify
text files (both interactively and via shell scripts). For most
purposes, ed has been replaced in normal usage by full-screen editors
(emacs and vi, for example).
What I've done is
- create a file intructions.ed containing
g/pattern/a\
this new line
w
q
... and save this file
- assume that original file and intructions.ed are in the same path, then type
ed original_file.txt < instructions.ed
- Done! you see a number at your screen, wich are bytes after and before been tracted by you intructions.ed file
sed are used for pattern substitutions but not usually for append a new line, that why I post this lines.
P.D There were a mistake at this entry I've fixed, you must finish with a backslah after final a (this a stands for append), otherwise it shouldn't perform anything...



