Ask Your Question

How to insert 500+ lines into an existing file

asked 2015-08-31 15:11:02 -0600

lclegg gravatar image

I need to insert 500+ lines into /etc/services on some systems. I'm a Puppet newbie using Open Puppet V4.2.1.

I am just not figuring out how to do this. I would rather not replace the entire /etc/services file but I could if I had to.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-09-01 06:09:57 -0600

look at using a template for your file, an erb script would manage this nicely.

alternatively could use a tool called augeus.

for templating have a look at:


and for augeas


edit flag offensive delete link more

answered 2015-09-02 04:48:07 -0600


Actually, you have multiple ways to do it, depending on what you really want to do.

First, you can use templates or static file resources which you already know.

Secondly, you can use the concat module so you can order bunch of texts/lines the way you want.

If you want to be more granular, you can use the file_line function so you can add/replace lines according to conditions like:

"add this line after the following line, etc...".

I don't suggest augeas as it works better with files with sections in it (obviously, that's not the case for /etc/services).

Check each one of these choices and choose the one that meets the best your requirements.

Regards, Rudy

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-08-31 15:11:02 -0600

Seen: 746 times

Last updated: Sep 02 '15