2

Given file alfa.txt:

10
11
12
13

I would like to append a line of text after every line. This is simple enough with sed:

$ sed aBRAVO alfa.txt
10
BRAVO
11
BRAVO
12
BRAVO
13
BRAVO

However I am having hard time with Ex:

$ ex -sc '%a|BRAVO' -cx alfa.txt
$ cat alfa.txt
10
11
12
13
BRAVO
2

append only supports a single line address, not a range. Here is a workaround with global:

ex -sc 'g/^/a|BRAVO' -cx alfa.txt

and with substitute:

ex -sc '%s/$/\rBRAVO/|x' alfa.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.