-2

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

2
  • 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).
    – roaima
    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. Sep 20, 2015 at 23:38

1 Answer 1

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.