1、列出子目录或子文件
hdfs dfs -ls +路径
2、创建目录(-p表示父目录都会创建
hdfs dfs -mkdir -p /001/mydemo/x/y/z
hdfs dfs -mkdir /001/mydemo3 /001/mydemo4 /001/mydemo5
3、列出文件夹中的文件
hdfs dfs -ls /001/mydemo
hdfs dfs -ls -R /001/mydemo
(-R表示列出所有子目录)
4、上传、移动、下载文件
4.1将本地目录txt1.txt文件上传到HDFS上并重命名为hdfs1.txt:
hdfs dfs -put txt1.txt /001/mydemo/hdfs1.txt
hdfs dfs -copyFromLocal txt2.txt /001/mydemo/hdfs2.txt
4.2本地文件移动到HDFS
hdfs dfs -moveFromLocal txt3.txt /001/mydemo/hdfs3.txt
4.3下载文件
hdfs dfs -get /001/mydemo/hdfs1.txt txt11.txt
hdfs dfs -copyToLocal /001/mydemo/hdfs3.txt txt3.txt
4.4文件合并再下载
hdfs dfs -getmerge /001/mydemo merge.txt
5、查看文件
查看HDFS下/001/mydemo/hdfs2.txt文件中的内容:
hdfs dfs -cat /001/mydemo/hdfs2.txt
hdfs dfs -text /001/mydemo/hdfs2.txt
6、删除文档
hdfs dfs -rm -r /001/mydemo/hdfs3.txt
7、文件或文件夹复制、移动
hdfs dfs -cp /001/mydemo/hdfs1.txt /001/mydemo/hdfs3.txt
hdfs dfs -mv /001/mydemo/hdfs3.txt /001/mydemo/hdfs4.txt
8、touchz 创建一个空文件file
hdfs dfs -touchz /001/mydemo/hdfs5.txt
9、count统计
hdfs dfs -count /001/mydemo(显示:目录个数, 文件个数, 文件总计大小 输入路径)
10、查看文件大小
hdfs dfs -du /001/mydemo
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。