symlink-copying a directory hierarchy

前端 未结 7 1661
孤独总比滥情好
孤独总比滥情好 2020-12-13 19:38

What\'s the simplest way on Linux to \"copy\" a directory hierarchy so that a new hierarchy of directories are created while all \"files\" are just symlinks pointing back to

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 20:03

    cp -as /root/absolute/path/name dest_dir
    

    will do what you want. Note that the source name must be an absolute path, it cannot be relative. Else, you'll get this error: "xyz-file: can make relative symbolic links only in current directory."

    Also, be careful as to what you're copying: if dest_dir already exists, you'll have to do something like:

    cp -as /root/absolute/path/name/* dest_dir/
    cp -as /root/absolute/path/name/.* dest_dir/
    

提交回复
热议问题