Hi, thanks for the reply.

Indeed that suggestion worked out in replacement of using `shell` module
(or similar).

Thanks for sharing.

On Thu, 20 Feb 2020 at 18:53, Vladimir Botka <[email protected]> wrote:

> On Thu, 20 Feb 2020 09:25:26 -0800 (PST)
> João Santos <[email protected]> wrote:
>
> >    - I have a file and want to insert in the beginning of each line the
> #
> >      character
> >    - No matter if it has 10 lines or 1000 lines
> >    - The final goal would be to no matter which file I said so, will add
> #
> >      to the beginning of line
>
> Use "replace" module. For example
>
> https://docs.ansible.com/ansible/latest/modules/replace_module.html#replace-replace-all-instances-of-a-particular-string-in-a-file-using-a-back-referenced-regular-expression
>
>     - replace:
>         path: "{{ item }}"
>         regexp: '^(.*)$'
>         replace: '# \1'
>       loop: "{{ list_of_files }}"
>
> HTH,
>
>         -vlado
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG3v9heUWvhdS9__KW_4ch6DPdRVZTAqgpDiUc47EminC6kZvg%40mail.gmail.com.

Reply via email to