Ask Your Question

Can you delete a set of lines from a text file using the line numbers [closed]

asked 2016-08-19 15:49:49 -0600

samt gravatar image


I am new to puppet. So my advance apologies if the question here doesn't make sense. What I am trying to accomplish here is that I have a text file, which has lots of entries. I would like to trim the file content before distribution. Here in this case, I would like to remove all the lines to the end of the file, after certain comment point.

Is is feasible to accomplish this using puppet?

Thanx, Sam

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by samt
close date 2016-08-22 18:00:26.607497

2 Answers

Sort by ยป oldest newest most voted

answered 2016-08-22 04:38:30 -0600

Mr_Sharma gravatar image

Hi Samt, As per my understanding Puppet is not best at text processing. This can be better done using sed or awk though you can include and trigger a sort of script or command from Puppet (using exec resource) if you like.

And if you are looking specifically at some text processing feature in puppet you can try with file_line or augeas resource. Depending on your use case or file format these might fit with your requirement.

Hope it helps.

edit flag offensive delete link more

answered 2016-08-22 17:59:44 -0600

samt gravatar image

Thanks Rajeev, for the thoughts. Guess that I may have to go with some file editing scripts and then have puppet call that and handle the editing. Thanks for all the assistance.

Thanx, Sam

edit flag offensive delete link more


Cool. You can hit LIKE if you liked my answer. :)

Mr_Sharma gravatar imageMr_Sharma ( 2016-08-23 02:59:20 -0600 )edit

Question Tools


Asked: 2016-08-19 15:49:49 -0600

Seen: 1,144 times

Last updated: Aug 22 '16