我正在编写一个shell脚本,将所有文件放在hadoop目录中。
我使用了命令:
hadoop dfs -put /opt/nikoo28/resources/conf ./现在,这将复制我的hadoop主目录中的文件夹conf覆盖所有内容。
但是,有一个文件, “doNotCopy.txt” ,我不想复制。 有什么方法可以跳过特定文件吗?
I am writing a shell script to put all my files in hadoop directory.
I used the command:
hadoop dfs -put /opt/nikoo28/resources/conf ./Now this copies the folder conf in my hadoop home directory overwriting everything.
However, there is one file, "doNotCopy.txt" which I do not want to copy. Is there some method by which I can skip a particular file?
最满意答案
在shell脚本中添加以下行:
mkdir /opt/copy mv /opt/nikoo28/doNotCopy.txt /opt/copy/doNotCopy.txt hadoop dfs -put /opt/nikoo28/resources/conf ./ && mv /opt/copy/doNotCopy.txt /opt/nikoo28/doNotCopy.txt只需将您不想复制的文件移动到其他文件夹即可。 执行hadoop fs -put命令。 现在,将文件移回原始位置。
如果要保留文件权限,请执行以下操作:
mkdir /opt/copy cp -p /opt/nikoo28/doNotCopy.txt /opt/copy/doNotCopy.txt rm /opt/nikoo28/doNotCopy.txt hadoop dfs -put /opt/nikoo28/resources/conf ./ && cp -p /opt/copy/doNotCopy.txt /opt/nikoo28/doNotCopy.txt注意:如果在创建目录,移动文件或复制文件时遇到权限错误,请添加sudo 。
Add these lines in your shell script:
mkdir /opt/copy mv /opt/nikoo28/doNotCopy.txt /opt/copy/doNotCopy.txt hadoop dfs -put /opt/nikoo28/resources/conf ./ && mv /opt/copy/doNotCopy.txt /opt/nikoo28/doNotCopy.txtJust move the file you don't want to copy to some other folder. Perform hadoop fs -put command. Now, move back the file to its original position.
If you want to preserve file permissions, then do this:
mkdir /opt/copy cp -p /opt/nikoo28/doNotCopy.txt /opt/copy/doNotCopy.txt rm /opt/nikoo28/doNotCopy.txt hadoop dfs -put /opt/nikoo28/resources/conf ./ && cp -p /opt/copy/doNotCopy.txt /opt/nikoo28/doNotCopy.txtNOTE: Add sudo if you get permission errors while creating directory, moving the file or copying the file.
更多推荐
发布评论