You have these three commands
mkdir test_dir test_dir1 test_dir2 test_dir3
touch file1 file2 file3
cp -v file* test_dir*/
Assuming no other files or directories in .
before the example is started, the wildcards in that last line get expanded thus:
cp -v file1 file2 file3 test_dir/ test_dir1/ test_dir2/ test_dir3/
(You can see this by changing cp
to echo cp
and observing the result.) What you didn't tell us is the diagnostic messages produced by cp -v
, which show what it is trying to do, i.e. copy every item on the command line but the last into the last item, which must therefore be a directory:
‘file1’ -> ‘test_dir3/file1’
‘file2’ -> ‘test_dir3/file2’
‘file3’ -> ‘test_dir3/file3’
cp: omitting directory ‘test_dir/’
cp: omitting directory ‘test_dir1/’
cp: omitting directory ‘test_dir2/’