hadoop fs -cmd < args >
1. ls 列出hdfs文件系統根目錄下的目錄和文件python
hadoop fs -ls /dir
hadoop fs -ls -R /dir --列出hdfs文件系統全部的目錄和文件
2.putoop
hadoop fs -put <local file> <hdfs file> --hdfs file的父目錄必定要存在,不然命令不會執行
hadoop fs -put <local file or dir> <hdfs dir> --hdfs dir 必定要存在,不然命令不會執行
hadoop fs -put - <hdfs file> --從鍵盤讀取輸入到hdfs file中,按Ctrl+D結束輸入,hdfs file不能存在,不然命令不會執行
3.getspa
hadoop fs -get <hdfs file> <local file or dir> --local file不能和 hdfs file名字不能相同,不然會提示文件已存在,沒有重名的文件會複製到本地
hadoop fs -get < hdfs file or dir > ... < local dir >
拷貝多個文件或目錄到本地時,本地要爲文件夾路徑
注意:若是用戶不是root, local 路徑要爲用戶文件夾下的路徑,不然會出現權限問題,
hadoop fs -rm < hdfs file > ...
hadoop fs -rm -r < hdfs dir>...
hadoop fs -mkdir <hdfs path> --只能一級一級的建目錄,父目錄不存在的話使用這個命令會報錯
hadoop fs -mkdir -p <hdfs path> --所建立的目錄若是父目錄不存在就建立該父目錄
6.cpcode
hadoop fs -cp <hdfs file> <hdfs file>
-- 目標文件不能存在,不然命令不能執行,至關於給文件重命名並保存,源文件還存在
hadoop fs -cp <hdfs file or dir> <hdfs dir> --目標文件夾要存在,不然命令不能執行
8.mv 移動blog
hadoop fs -mv <hdfs file> <hdfs file>
目標文件不能存在,不然命令不能執行,至關於給文件重命名並保存,源文件不存在hadoop
hadoop fs -mv < hdfs file or dir >... < hdfs dir >
源路徑有多個時,目標路徑必須爲目錄,且必須存在。
注意:跨文件系統的移動(local到hdfs或者反過來)都是不容許的
9.count get
hadoop fs -count <hdfs path> --統計hdfs對應路徑下的目錄個數,文件個數,文件總計大小
10.textcmd
hadoop fs -text < hdsf file>
將文本文件或某些格式的非文本文件經過文本格式輸出
11.catclass
hadoop fs -cat <hdfs file>/*
hadoop fs -cat /user/hive/back/hs_ods/clientinfo/* >clientinfo.txt
-- 將文件保存到local 文件
補充知識:cli
MR的運行依賴數據地址,若是數據地址不存在,則會報錯
12. 在打開的結果中搜索
hadoop dfs -cat /user/hive/warehouse/fundmarket/* |grep '華夏'