复制hadoop目录中除1之外的所有文件(Copy all files in hadoop directory except 1)

编程入门 行业动态 更新时间:2024-10-14 22:20:33
复制hadoop目录中除1之外的所有文件(Copy all files in hadoop directory except 1)

我正在编写一个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.txt

Just 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.txt

NOTE: Add sudo if you get permission errors while creating directory, moving the file or copying the file.

更多推荐

本文发布于:2023-08-03 20:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1400328.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   目录中   hadoop   directory   files

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!