jeesshnasree
Flight Engineer
Flight Engineer
  • 284 Views

how to copy specific folder under only one or 2 specific file in linux

Jump to solution

Hello All,

 

i have environment in Linux OS but one help required from your end regarding copy .
now explaining description :

 

I have FS structure like this :

 

/opt/DevOps/profile/instances/webA/serverices.xml file ,but under webA contain so many files but i need to copy from source path to in /tmp  path copy only "webA/services.xml" ( source file  with WebA)
similarly copy "webB/services.xml" & "webC/services.xml" .

here in every FS "services.xml"  file is common but i need to copy with "webA/services.xml from source to /tmp , webB/services.xml & webC/services.xml .

output sould like :

 

/tmp/webA/services.xml 
/tmp/webB/services.xml 
/tmp/webC/services.xml 

 

Note : without create directory under /tmp with WebA,webB,webC but file need to copy respective folder only with specific file copy .


any command for copy like above mentioned output .

could you please share me command if possible .

i am waiting for your valuable reply .

Regards,

Jeesshnasree

 

0 Kudos
1 Solution

Accepted Solutions
matteoclc
Flight Engineer
Flight Engineer
  • 244 Views

Re: how to copy specific folder under only one or 2 specific file in linux

Jump to solution

Did you try with "man cp" ?

 

cd /opt/DevOps/profile/instances && cp --parents web{A,B,C}/services.xml /tmp/.
--
Matteo Calcagnini

View solution in original post

Reply
Loading...
4 Replies
Tracy_Baker
Starfighter Starfighter
Starfighter
  • 255 Views

Re: how to copy specific folder under only one or 2 specific file in linux

Jump to solution

Maybe this?

First, make directories (if it they don't already exist)

mkdir -pv /tmp/Web{A,B,C}

copy file into all directories

for i in A B C; do cp -v services.xml /tmp/Web${i}; done

Program Lead at Arizona's first Red Hat Academy, est. 2005
Estrella Mountain Community College
0 Kudos
Reply
Loading...
matteoclc
Flight Engineer
Flight Engineer
  • 246 Views

Re: how to copy specific folder under only one or 2 specific file in linux

Jump to solution
 
--
Matteo Calcagnini
0 Kudos
Reply
Loading...
matteoclc
Flight Engineer
Flight Engineer
  • 245 Views

Re: how to copy specific folder under only one or 2 specific file in linux

Jump to solution

Did you try with "man cp" ?

 

cd /opt/DevOps/profile/instances && cp --parents web{A,B,C}/services.xml /tmp/.
--
Matteo Calcagnini

View solution in original post

Reply
Loading...
jeesshnasree
Flight Engineer
Flight Engineer
  • 145 Views

Re: how to copy specific folder under only one or 2 specific file in linux

Jump to solution

Hello @matteoclc ,

 

Thank you share and it's working fine .

0 Kudos
Reply
Loading...
Join the discussion
You must log in to join this conversation.