2

有什么方法可以使用 HDFS 命令将 hdfs 文件的文本内容复制到另一个文件系统中:

 hadoop fs -text /user/dir1/abc.txt

我可以使用 -cat 或任何方法将 -text 的输出打印到另一个文件中吗?:

 hadoop fs -cat /user/deepak/dir1/abc.txt 
4

4 回答 4

2

正如文档中所写,您可以使用它hadoop fs -cp来复制hdfs. 您可以使用hadoop fs -copyToLocal将文件从本地文件系统复制hdfs到本地文件系统。如果要将文件从一个复制hdfs到另一个,请使用DistCp 工具

于 2014-08-22T07:46:34.720 回答
0

谢谢我确实在 hadoop-home lib 文件夹中使用了流媒体 jar 示例,如下所示:

hadoop -jar hadoop-streaming.jar -input hdfs://namenode:port/path/to/sequencefile \
-output /path/to/newfile -mapper "/bin/cat" -reducer "/bin/cat" \
-file "/bin/cat" -file "/bin/cat" \
-inputformat SequenceFileAsTextInputFormat

如果您想计算 hdfs 序列文件中的行数,可以使用“/bin/wc”。

于 2014-08-22T09:59:39.617 回答
0

作为一般命令行提示,您可以将|其用于另一个程序或>文件>>,例如

# Will output to standard output (console) and the file /my/local/file
# this will overwrite the file, use ... tee -a ... to append
hdfs dfs -text /path/to/file | tee /my/local/file

# Will redirect output to some other command
hdfs dfs -text /path/to/file | some-other-command

# Will overwrite /my/local/file
hdfs dfs -text /path/to/file > /my/local/file

# Will append to /my/local/file
hdfs dfs -text /path/to/file >> /my/local/file
于 2014-08-22T09:25:51.910 回答
0

您可以使用以下内容:

  1. 复制到本地
    hadoop dfs -copyToLocal /HDFS/file /user/deepak/dir1/abc.txt
  2. 合并
    hadoop dfs -getmerge /HDFS/file /user/deepak/dir1/abc.txt
  3. 得到
    hadoop dfs -get /HDFS/file /user/deepak/dir1/abc.txt
于 2014-08-22T10:14:16.783 回答