标签:pre 显示文件 显示 删除目录 linux文件 开头 原来 input 系统
一、Hadoop提供的Shell命令完成相同任务:
cd /usr/local/hadoop
touch hello.txt
cat hello.txt
./sbin/start-dfs.sh ./bin/hdfs dfs -mkdir -p /user/hadoop ./bin/hdfs dfs -mkdir input ./bin/hdfs dfs -put ./hello.txt input
./bin/hdfs dfs -ls /input
./bin/hdfs dfs -cat input/hello.txt
./bin/hdfs dfs -rm -ls input/hello.txt
./bin/hdfs dfs -get input/test.txt ~/hello.txt
./bin/hdfs dfs -rm -ls input/hello.txt
二、
if $(hdfs dfs -test -e hello.txt); then $(hdfs dfs -appendToFile local.txt hello.txt); else $(hdfs dfs -copyFromLocal -f local.txt hello.txt); fi
if $(hdfs dfs -test -e file: then $(hdfs dfs -copyToLocal hello.txt ./hello2.txt); else $(hdfs dfs -copyToLocal hello.txt ./hello.txt); fi
hdfs dfs -cat hello.txt
hdfs dfs -ls -h hello.txt
hdfs dfs -ls -R -h /user/hadoop
if $(hdfs dfs -hello -d dir1/dir2); then $(hdfs dfs -touchz dir1/dir2/filename); else $(hdfs dfs -mkdir -p dir1/dir2 && hdfs dfs -touchz dir1/dir2/filename); fi
if $(hdfs dfs -hello -d dir1/dir2); then $(hdfs dfs -touchz dir1/dir2/filename); else $(hdfs dfs -mkdir -p dir1/dir2); fi if$(hdfs dfs -rmdir dir1/dir2); then $(hdfs dfs -rmdir dir1/dir2) fi
hdfs dfs -appendToFile local.txt hello.txt hdfs dfs -get hello.txt cat text.txt >> local.txt hdfs dfs -copyFromLocal -f hello.txt hello.txt
hdfs dfs -rm hello.txt
删除目录(如果目录非空则会提示not empty,不执行删除):hdfs dfs -rmdir dir1/dir2
强制删除目录:hdfs dfs -rm -R dir1/dir2
hdfs dfs -mv hello.txt hello2.txt
标签:pre 显示文件 显示 删除目录 linux文件 开头 原来 input 系统
原文地址:https://www.cnblogs.com/lg916843/p/8964162.html