# cannot stat command with \* and \`

**URL:** <https://forum.ansible.com/t/cannot-stat-command-with-and/14527>\
**Category:** Ansible Project\
**Created:** [February 9, 2014, 6:06am UTC](https://forum.ansible.com/t/cannot-stat-command-with-and/14527 "2014-02-09T06:06:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naoko\_Reeves](https://avatars.discourse-cdn.com/v4/letter/n/e19adc/32.png) [@Naoko\_Reeves](https://forum.ansible.com/u/Naoko_Reeves)\
**Post date:** [February 9, 2014, 6:06am UTC](https://forum.ansible.com/t/cannot-stat-command-with-and/14527/1 "2014-02-09T06:06:49Z")

</div>

I am trying to rename folder that is unpacked. So I can only get file name accurately with grep (or some sort of regex expression)

via ansible, the following command fails with the error message: stderr: mv: cannot stat `/var/www/`ls /var/www/ | grep client`': No such file or directory

command mv “/var/www/`ls /var/www/ | grep client`” “/var/www/gd\_new”

however, exact command works just fine when executed on server

I try to use mv “var/www/client\*” “/var/www/gd\_new”, with xargs with pipe… all end up with similar error…

any guidance would be appreciated.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [February 9, 2014, 1:14pm UTC](https://forum.ansible.com/t/cannot-stat-command-with-and/14527/2 "2014-02-09T13:14:07Z")

</div>

can you show the play/tasks involved?

---

<div class="post-metadata">

**Author:** ![Naoko\_Reeves](https://avatars.discourse-cdn.com/v4/letter/n/e19adc/32.png) [@Naoko\_Reeves](https://forum.ansible.com/u/Naoko_Reeves)\
**Post date:** [February 9, 2014, 1:55pm UTC](https://forum.ansible.com/t/cannot-stat-command-with-and/14527/3 "2014-02-09T13:55:11Z")

</div>

yes this is the task. only “mv” fails…

- name: example\_client | download archived dist, unpack and cleanup  
command: “{{item}}”  
with\_items:
- curl -H “Authorization:token {{ git\_token }}” -L -o /var/www/example.zip “[https://api.github.com/repos/user/example\_client/zipball/gh-pages](https://api.github.com/repos/user/example_client/zipball/gh-pages)”
- unzip /var/www/example.zip -d /var/www
- **mv** “/var/www/`ls /var/www/ | grep client`” “/var/www/example\_new”  
tags:
- deploy

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [February 9, 2014, 3:06pm UTC](https://forum.ansible.com/t/cannot-stat-command-with-and/14527/4 "2014-02-09T15:06:28Z")

</div>

Substitute "command" by "shell". The shell module allows to do piping, backticks, globs, etc.. The command module does not do any of those things and can only be used for a single static command line.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 9, 2014, 9:22pm UTC](https://forum.ansible.com/t/cannot-stat-command-with-and/14527/5 "2014-02-09T21:22:51Z")

</div>

Yes, you need to use the shell module. However, much of this can be refactored.

curl should probably use the “get\_url” module, etc.

There’s also the “unarchive” module, so you could do a local play to download the contents to the Ansible control machine and follow that up with unarchive to avoid the download happening on every host.

---

<div class="post-metadata">

**Author:** ![Naoko\_Reeves](https://avatars.discourse-cdn.com/v4/letter/n/e19adc/32.png) [@Naoko\_Reeves](https://forum.ansible.com/u/Naoko_Reeves)\
**Post date:** [February 9, 2014, 9:39pm UTC](https://forum.ansible.com/t/cannot-stat-command-with-and/14527/6 "2014-02-09T21:39:46Z")

</div>

Dag, Michael,  
Thank you, that solved the issue.
