Error when running this command, I think the command is clear to get the idea.

cp file.txt /folder/*/*/*/file.txt

I found out cp dosen't support *, so how can I do the same thing in bash or command-line

  • 1
    The wildcards are handled by the shell already. If cp is complaining at you it's because your wildcarded path is matching more than one file (and the last match is not a directory). Commented Sep 20, 2015 at 23:13
  • 2
    What are you trying to achieve? FYI, cp copies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. Your command doesn't seem to have a DIRECTORY at the end. Commented Sep 20, 2015 at 23:38

1 Answer 1

for i in /folder/*/*/*
   [ -d "$i" ] && cp file.txt "$i"

Not the answer you're looking for? Browse other questions tagged .