Reputation: 11081
When I execute the following command (which moves all files with the .txt
and .sbreaks
extension to another folder):
sudo docker exec name mv xyz/data/outputs/*.{sbreaks,txt} <>/data/spare
I get the following error:
mv: cannot stat ‘xyz/data/outputs/*.sbreaks’: No such file or directory
mv: cannot stat ‘xyz/data/outputs/*.txt’: No such file or directory
But, when I go into docker via sudo docker exec -it name bash
and execute the same command: mv xyz/data/outputs/*.{sbreaks,txt} xyz/data/spare
, it executes fine.
What am I doing wrong here?
PS: Both local and the Docker container are ubuntu environments
Upvotes: 2
Views: 1793
Reputation: 36833
That is because the *
is expanded by a shell program (i.e. bash). (Psst, this is typical interview question).
So pass your command to a shell and let it launch the mv
for you:
sudo docker exec cypher bash -c 'mv xyz/data/outputs/*.{sbreaks,txt} .......'
When you do docker exec some_program some_param
, docker searches for some_program
and executes it directly without doing anything extra, and just pass some_param
as a parameter (a star in your case). mv
expects real file names, and not *
.
Upvotes: 10