Wild card for dir path

I have dir structure like this :

         /opt/oracle/product/abc/sqlplus/admin/
         /opt/oracle/product/def/sqlplus/admin
         /opt/oracle/product/ghi/sqlplus/admin
         

I am trying to use wildcard ( for dirs abc,def,ghi) ..something like this :


cp xyz.txt  /opt/oracle/product/*/sqlplus/admin

giving me error as :No such file or dir?

is there a way to do it ?

Thanks

Remember that wildcards happen in the shell... If that worked, it would expand to

cp file dir1 dir2 dir3

which would mean what? Copy file, dir1, dir2 into dir3. Not what you intended probably.

To copy the same file n times into n different places:

for DIR in /opt/oracle/product/*/sqlplus/admin
do
        cp file "$DIR"/
done
1 Like