- 首先啟動hadoop
cd /usr/local/hadoop
./sbin/start-dfs.sh
-
在hdfs的“/user/hadoop”目錄下創(chuàng)建file1.txt
./bin/hdfs dfs -touchz file1.txt -
初始化文件,并向文件中寫入內(nèi)容
./bin/hdfs dfs -get /user/hadoop/file1.txtvi file1.txt./bin/hdfs dfs -put -f file1.txt /user/hadoop/file1.txt./bin/hdfs dfs -cat file1.txt

查看file1.txt內(nèi)容
-
在hdfs的“/user/hadoop”目錄下創(chuàng)建file2.txt
./bin/hdfs dfs -touchz file2.txt -
向file2.txt追加內(nèi)容
echo "<this is file2.txt>" | ./bin/hdfs dfs -appendToFile - file2.txt -
查看file2.txt內(nèi)容
./bin/hdfs dfs -cat file2.txt
查看file2.txt內(nèi)容
-
修改file2.txt.的內(nèi)容
./bin/hdfs dfs -get /user/hadoop/file2.txtvi file2.txt./bin/hdfs dfs -put -f file2.txt /user/hadoop/file2.txt -
查看修改內(nèi)容
./bin/hdfs dfs -cat file2.txt
修改file2

