mardi 27 août 2019

Regex patterns in find module (Ansible)

Basically I'm trying to get a return of filenames (directories, actually) in a server. I only want those files with 3 (and only 3) characters.

I even tried to use the 'exclude' parameter ( excludes: '\S{4,}' ), to make sure it would work. It didn't.

Here's a sample of the code:

  - find:
      paths: /workdir
      file_type: directory
      use_regex: yes
      patterns: '\S{3}'
    register: oea

  - debug:
      msg: ""
    with_items: ""

I expect all files with 3 and only 3 characters, but the actual output is every directory under /workdir.

Am I using the regex pattern the wrong way?

Aucun commentaire:

Enregistrer un commentaire