# Ansible search and cut from stdout\_lines in variable

**URL:** <https://forum.ansible.com/t/ansible-search-and-cut-from-stdout-lines-in-variable/37474>\
**Category:** Ansible Project\
**Created:** [December 16, 2022, 10:07am UTC](https://forum.ansible.com/t/ansible-search-and-cut-from-stdout-lines-in-variable/37474 "2022-12-16T10:07:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dbibi\_Amine](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@Dbibi\_Amine](https://forum.ansible.com/u/Dbibi_Amine)\
**Post date:** [December 16, 2022, 10:07am UTC](https://forum.ansible.com/t/ansible-search-and-cut-from-stdout-lines-in-variable/37474/1 "2022-12-16T10:07:11Z")

</div>

Hello,

I didnt find a solution to get this line /opt/bea/cfgtoollogs/opatch/opatch2022-12-16\_10-44-20AM\_1.log", from stdout\_lines

thanks 🙂

![Capture.PNG](https://us1.discourse-cdn.com/ansible/original/2X/d/deabe97ae9eca73326f0ed4c012b43222a9303a1.png)

stdout\_lines": [  
“Programme d’installation des patches temporaires Oracle version 13.9.4.2.8”,  
“Copyright (c) 2022, Oracle Corporation. Tous droits réservés.”,  
“”,  
“”,  
“Répertoire de base Oracle : /opt/bea”,  
“Inventaire central : /appli/weblogic/oraInventory”,  
" à partir de : /opt/bea/oraInst.loc",  
“Version d’OPatch : 13.9.4.2.8”,  
“Version d’OUI : 13.9.4.0.0”,  
“Emplacement du fichier journal : /opt/bea/cfgtoollogs/opatch/opatch2022-12-16\_10-44-20AM\_1.log”,  
“”,  
“”,  
“OPatch detects the Middleware Home as "/opt/bea\_12.2.1.3.0"”,  
“”,  
“”,  
"Patches will be rolled back in the following order: “,  
" 32148634”,  
"The following patch(es) will be rolled back: 32148634 ",  
“”,  
“Arrêtez les instances Oracle exécutées depuis ce répertoire de base ORACLE\_HOME sur le système local.”,  
“(Répertoire de base Oracle = ‘/opt/bea’)”,  
“”,  
“”,  
“Le système local est-il prêt pour l’application du patch ? [y|n]”,  
“Y (auto-answered by -silent)”,  
“User Responded with: Y”,  
“”,  
“Rolling back patch 32148634…”,  
“”,  
“RollbackSession : annulation (rollback) du patch temporaire ‘32148634’ dans le répertoire de base Oracle ‘/opt/bea’”,  
“”,  
“Application d’un patch au composant oracle.wls.core.app.server, 12.2.1.3.0…”,  
“RollbackSession : suppression du patch temporaire ‘32148634’ de l’inventaire”,  
“Log file location: /opt/bea/cfgtoollogs/opatch/opatch2022-12-16\_10-44-20AM\_1.log”,  
“”,  
“OPatch succeeded.”  
]

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [December 16, 2022, 1:21pm UTC](https://forum.ansible.com/t/ansible-search-and-cut-from-stdout-lines-in-variable/37474/2 "2022-12-16T13:21:52Z")

</div>

On this page [https://www.tailored.cloud/devops/how-to-filter-and-map-lists-in-ansible/](https://www.tailored.cloud/devops/how-to-filter-and-map-lists-in-ansible/)

> use “ **select** ” filter to filter a list and “ **match** ” to combine it with reg expressions, like:
> 
> “{{ ansible\_interfaces | **select(‘match’, ‘^(eth|wlan)[0-9]+’)** | list }}”

In your case maybe this will work:

- debug:  
msg: “{{ rollbacks.stdout\_lines | select(‘match’, ‘/opt/bea/cfgtoollogs/opatch’) | list }}”

Walter

---

<div class="post-metadata">

**Author:** ![Dbibi\_Amine](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@Dbibi\_Amine](https://forum.ansible.com/u/Dbibi_Amine)\
**Post date:** [December 19, 2022, 3:00pm UTC](https://forum.ansible.com/t/ansible-search-and-cut-from-stdout-lines-in-variable/37474/3 "2022-12-19T15:00:24Z")

</div>

Résolved :  
link: “{{ rollbackspu.stdout\_lines | select(‘match’,‘Log file location:’) | list }}”

thank you Walter
