Deep Mukherjee
Deep Mukherjee

Reputation: 25

How to take backup of a file using find command

I have a file "backup". I want to find that particular file and take a backup with cp command and the backup file will be "backup_b".

The code which i am executing is below

find /u01/app/gafmbs/backup_b -exec cp backup_b backup

But this is not working. How will i do that? Can anybody help me out?

Upvotes: 0

Views: 1215

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136266

You are not invoking find correctly.

A fix:

find /u01/app/gafmbs -name backup_b -exec cp {} backup \;
     ^               ^                       ^         ^
     |               |                       |         |
     where to look   |                       |         exec command terminator
                     what to look for        |
                                             paths to found files

Upvotes: 1

Related Questions