标签:else 读写权限 删除 完成 shell 下载 覆盖 article 不为
一、Hadoop提供的Shell命令完成相同任务:
1.在本地Linux文件系统的“/home/hadoop/”目录下创建一个文件txt,里面可以随意输入一些单词.
mkdir hadoop
cd hadoop
touch test.txt
gedit test.txt
./sbin/start-dfs.sh ./bin/hdfs dfs -mkdir -p /user/hadoop ./bin/hdfs dfs -mkdir input ./bin/hdfs dfs -put ./test.txt input
./bin/hdfs dfs -ls input
./bin/hdfs dfs -ls /input ./bin/hdfs dfs -cat input/test.txt
cd hadoop rm -r test.txt ls -al
./bin/hdfs dfs -get /input/test.txt ~/hadoop
./bin/hdfs dfs -rm -ls input/test.txt
二、
hadoop fs -put /home/hadoop/test.txt /usr/local/hadoop
hadoop fs -test -e /usr/local/hadoop/test.txt
if $(hadoop fs -test -e /home/hadoop/test.txt); <br>then $(hadoop fs -copyToLocal /usr/local/hadoop/test.txt /home/hadoop/test.txt);<br>else $(hadoop fs -copyToLocal /usr/local/hadoop/test.txt /home/hadoop/test2.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
标签:else 读写权限 删除 完成 shell 下载 覆盖 article 不为
原文地址:https://www.cnblogs.com/darkhate/p/8964158.html