cancel
Showing results for 
Search instead for 
Did you mean: 
jeesshnasree
Starfighter Starfighter
Starfighter
  • 2,514 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
  • 2,474 Views

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

4 Replies
Tracy_Baker
Starfighter Starfighter
Starfighter
  • 2,485 Views

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
matteoclc
Flight Engineer
Flight Engineer
  • 2,476 Views
 
--
Matteo Calcagnini
0 Kudos
matteoclc
Flight Engineer
Flight Engineer
  • 2,475 Views

Did you try with "man cp" ?

 

cd /opt/DevOps/profile/instances && cp --parents web{A,B,C}/services.xml /tmp/.
--
Matteo Calcagnini
jeesshnasree
Starfighter Starfighter
Starfighter
  • 2,375 Views

Hello @matteoclc ,

 

Thank you share and it's working fine .

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