12

Is it possible to write text from the command line into Hadoop?

Trying to do something similar to the unix write/append to file command.

echo "hello world" > hello_world.txt

In Hadoop land I would expect this to work, but the commands do not.

hadoop fs -appendToFile "foo bar" /dir/hadoop/hello_world.txt

hadoop fs -put "hello world" /dir/hadoop/hello_world.txt
user2601995
  • 6,463
  • 8
  • 37
  • 41

1 Answers1

31

Hadoop document states appendToFile and put can read stdin

echo "hello world" | hadoop fs -appendToFile - /dir/hadoop/hello_world.txt

echo "hello world" | hadoop fs -put - /dir/hadoop/hello_world.txt

user2601995
  • 6,463
  • 8
  • 37
  • 41