Reputation: 21
Recently I've been trying to pick up Linux bash commands (Using win-bash) and I was intrigued by wildcards so I decided to try them out. I had my friend create a folder containing random files with random strings and I want to copy every file that has only 4 characters and it displayed that ???? is not a file or directory
.
I used the command: cp ???? dir
So.. can someone explain how does the question marks work and how can I properly utilize the wildcards?
Upvotes: 1
Views: 1132
Reputation: 531858
bash
treats ????
as a glob, and tries to replace it with a list of any files matching it. If that match fails, then it leaves it as a literal string, rather than raising an error that it cannot find any matches. This literal string is then passed to cp
, which cannot find a file named "????", and so it raises the error you see.
Upvotes: 3