I have a directory:/home/username1/dir_1This directory contains two folders, folder_1 and folder_2. In folder_2 are links to files present in folder_1.Now, I want to copy dir_1 into /home/username2/dir_2, and the links that are in the new folder_2 should point to the files that are in the new folder_1. So, the new directory /home/username1/dir_1 is completely independent from the old one /home/username2/dir_2.Is that possible ?
Copy a directory containing links and their targets in Linux
files
Yes, assuming that your question has somewhat mixed information about how the depencies actually should be (I presume here you've mixed dir_1 and dir_2 towards the end), rsync(1) will do that for you:rsync -r -l /home/username1/dir_1/ /home/username1/dir_2/Relevant switches being-l, --links                 copy symlinks as symlinks-r, --recursive             recurse into directoriesOr you could just go with easiest possible choice, using -a which implies (among other things) -l and -r:rsync -a /home/username1/dir_1/ /home/username1/dir_2/