📅 2019-Jan-21 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ copy, rsync ⬩ 📚 Archive
From a certain directory I wanted to copy a file
a/b/c.txt to a destination. But I wanted the relative path
a/b to be retained at the destination. A normal copy would just copy
c.txt to the destination.
There is no way to do this using the
cp command. One solution is to use rsync which supports maintaining the relative file path.
$ pwd /home/joe/workspace/foobar $ rsync -R a/b/c.txt /home/joe/destination
/home/joe/destination/a/b automatically creating
a/b if they do not exist in the destination.