[英]Linux cp with full paths
How to copy file to dir with full file destination path? 如何将文件复制到具有完整文件目标路径的目录?
When i use: 当我使用时:
cp --parents /etc/passwd /tmp
I get an error 我得到一个错误
cp: illegal option -- - usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... target_directory
And if i using this script 如果我使用此脚本
for line in "`cat fromDirs.txt`"; do find "$line" -type f \( -name '*good*' -o -exec grep -F "(NODES_'TASK')" {} \; \) -exec cp {} /tmp/ \;; done
maybe there are possibility to concatenate the variables like 也许有可能将像
-exec cp $line{} /tmp/ \;; done
or
-exec cp {} /tmp/$line \;; done
??? ???
The problem is your version of cp
does not accept long options. 问题是您的
cp
版本不接受长选项。 When it sees --parents
it thinks you are trying to use the -
option (as well as the p
, a
, r
, etc. options). 当它看到
--parents
它认为您正在尝试使用-
选项(以及p
, a
, r
等选项)。
You can emulate it like this: 您可以像这样模拟它:
source=/etc/passwd
mkdir -p /tmp/$(dirname $source)
cp $source /tmp/$source
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.