scp command problem

I am trying to copy file . On the remote host I have dir structure as ...

/opt/product/11.2.0/

and underneath 11.2.0 I have db and db112 dirs.. and there are sub dirs underneath db and db112..

scp xyx:/tmp/1.sh /opt/oracle/11.2.0/*/hs/admin/1.sh

the idea here is copy 1.sh to both db and db112 . how to use copy command for this purpose

Thanks in advance.

There's no direct way to do that as far as I know.

Either you open two connections to the remote server or you just locally copy the file after the first transmission. Something like:

scp xyx:/tmp/1.sh /opt/oracle/11.2.0/db/hs/admin/1.sh && cp /opt/oracle/11.2.0/db/hs/admin/1.sh /opt/oracle/11.2.0/db112/hs/admin/1.sh

This works fine if you only have two different target directories (db &db112).

Now, if you had -say- 1000+ different destination folders, then perhaps a script would be a better solution.

EDIT: Or you could use PSSH

If all the destination files are already present (update), you can use

ssh xyx 'cat /tmp/1.sh' | tee /opt/oracle/11.2.0/*/hs/admin/1.sh >/dev/null

Otherwise you can try

ssh xyx 'cat /tmp/1.sh' | tee /opt/oracle/11.2.0/{db,db112}/hs/admin/1.sh >/dev/null
1 Like