I have a requirement where I need to copy some files from one location to other (Where the file may exist). While doing so,
- I need to take a backup if the file already exists.
- Copy the new file to the same location
I am facing problem in point 2. While I am trying to get the destination path for copying files, I am unable to extract the directory of the file. I tried using various options of find command, but was unable to crack it.
I need to trim the file name from the full file path so that it can be used in cp command. I am new to shell scripting. Any pointers are appreciated.