1、Hadoop提供的Shell命令完成相同任務:python
cd /home/hadoop/
touch test.txt
cat temp.txt
cd /usr/local/hadoop ./bin/hdfs dfs -put /home/hadoop/test.txt input ./bin/hdfs dfs -ls input
./bin/hdfs dfs -cat input/test.txt rm -rf test.txt ls
./bin/hdfs dfs -get input/text.txt /home/hadoop ./bin/hdfs dfs -rm -r input/text.txt ./bin/hdfs dfs -ls input
2、app
if $(hdfs dfs -test -e test.txt); then $(hdfs dfs -appendToFile local.txt test.txt); else $(hdfs dfs -copyFromLocal -f local.txt test.txt); fi
if $(hdfs dfs -test -e file: then $(hdfs dfs -copyToLocal hello.txt ./test2.txt); else $(hdfs dfs -copyToLocal hello.txt ./test.txt); fi
hadoop fs -cat /usr/local/hadoop/test.txt
hadoop fs -ls -h /usr/local/hadoop/test.txt
hadoop fs -ls -R -h /usr/local/hadoop
if $(hadoop fs -test -d /usr/local/hadoop/test); then $(hadoop fs -touchz /usr/local/hadoop/test/test1.txt); else $(hadoop fs -mkdir -p /usr/local/hadoop/test && hadoop fs -touchz /usr/local/hadoop/test/test1.txt); fi
hadoop fs -rmr /usr/local/hadoop/test
hadoop fs -appendToFile local.txt test.txt
hadoop fs -rm /usr/local/hadoop/test.txt
hadoop fs -rmr /usr/local/hadoop
hadoop fs -mv /usr/local/hadoop/test.txt /usr/local/hadoop/hadoop_tmp/test.txt