Ind*_*our 0 unix linux shell hadoop
我想从hadoop文件系统中读取unix框中的逐行记录:
示例 -
while read line
do
echo "input record " $line
###some other logic i have here....
done < /user/want/to/read/from/hadoop/part00
Run Code Online (Sandbox Code Playgroud)
上面的代码片段显示错误 -
**: cannot open [No such file or directory]**
Run Code Online (Sandbox Code Playgroud)
如何使用Unix工具从Hadoop中读取?
使用该hadoop fs命令可以访问这些文件的内容:
while IFS= read -r line; do
echo "Read: $line"
done < <(hadoop fs -cat hdfs://nodename/filename)
Run Code Online (Sandbox Code Playgroud)
注意,<()构造需要bash; 因此,你的脚本需要从而开始#!/bin/bash,而不是#!/bin/sh.