user212051
user212051

Reputation: 93

Copy files with the same names to their own places in one command

I need to copy files with the same name in multiple directories to their same places,

For Example, Files are as follows:

/var/Aug/test 

/var/Sep/test 

/var/Oct/test

And I need to copy them to their own places but named test_1

/var/Aug/test_1 

/var/Sep/test_1 

/var/Oct/test_1

if I run ls command

ls /var/Aug

Output should be:

test test_1

Upvotes: 0

Views: 38

Answers (1)

Kent
Kent

Reputation: 195029

give this a try:

 find . -name 'test'|xargs -I{} cp {} "{}_1"

Upvotes: 1

Related Questions