Ask Your Question

inplace line manipulation

asked 2013-03-09 15:54:48 -0600

Hi Everybody, I'm searching for a way to manipulate file lines using patterns i.e. existing patterns is git+ssh:// and i want to change its occurrence to git+

I've checked file_line{} resource in puppetlabs stdlib, but actually it didn't fit my case

so can any one recommend any other way rather than templating this file

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-09 16:34:29 -0600

Daenney gravatar image

updated 2013-03-15 12:35:41 -0600

I'm afraid that's a really tough one.

To manage parts of files, lines or anything else, you have a few options:

  • Augeas
  • file_line
  • concat
  • template magic

I tend to use concat mostly now. With concat you define a file and fragments of that file, plus the order in which they occur. That way, you can manage single lines or groups of lines or blocks of configuration within a configuration file.

Unfortunately for your case what you seem to need is some sed magic to rewrite parts of your configuration. I'm not aware of any good way to ... (more)

edit flag offensive delete link more

answered 2013-03-14 04:37:33 -0600

Like Daenney suggested, Augeas might be the best option for you. What is the format of the file?

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


Asked: 2013-03-09 15:54:48 -0600

Seen: 121 times

Last updated: Mar 15 '13