我已经制作了一个rpm
软件包来安装程序,并且复制文件所需的文件夹之一是symbolic link
,因为符号链接指向的程序可能会随着时间的推移而发生变化通过将文件复制到rpm
而不是硬编码路径,可以更轻松地维护symbolic link
包的构建。但是,我收到了错误
cp: cannot overwrite directory with non-directory
当rpm
包尝试将文件复制到符号链接文件夹时。为什么会发生这种情况,有什么办法可以解决这个错误,然后将文件复制到symbolic link
指向的文件夹中?我正在运行RHEL 6.6
。
答案 0 :(得分:1)
该错误通常意味着您告诉cp将目标视为普通文件(-T
参数)。
$ ls -lR
.:
total 16
drwxr-xr-x 2 root root 4096 Feb 6 09:46 dir
-rw-r--r-- 1 root root 0 Feb 6 09:45 file
lrwxrwxrwx 1 root root 3 Feb 6 09:45 symdir -> dir
./dir:
total 0
$ cp -T file symdir
cp: cannot overwrite non-directory `symdir' with non-directory
$ ls -lR
.:
total 16
drwxr-xr-x 2 root root 4096 Feb 6 09:46 dir
-rw-r--r-- 1 root root 0 Feb 6 09:45 file
lrwxrwxrwx 1 root root 3 Feb 6 09:45 symdir -> dir
./dir:
total 0
$ cp file symdir
$ ls -lR
.:
total 16
drwxr-xr-x 2 root root 4096 Feb 6 09:46 dir
-rw-r--r-- 1 root root 0 Feb 6 09:45 file
lrwxrwxrwx 1 root root 3 Feb 6 09:45 symdir -> dir
./dir:
total 4
-rw-r--r-- 1 root root 0 Feb 6 09:46 file