I mess with Hadoop. Launched hdfs namenode -format. He gave some errors that I did not see because the lines ran too fast. I tried to write

hdfs namenode -format | ls hdfs namenode -format > result.txt 

.. however, this and other results did not work.

Did I do the right thing? Why could not manage the output?

  • one
    @KutaBeach, if I'm not confusing anything, so you only control stdout, and errors can fly to stderr. Here I am completely swimming, but it seems that 2> & 1 will redirect stderr to stdout: hdfs namenode -format> result.txt 2> & 1 What to | ls | ls , then ls lists the contents of the directory, you hardly wanted to use this command. - etki
  • one
    @Etki is better because hdfs namenode -format &> result.txt, and interactively, really hdfs namenode -format 2> & 1 | less - zb '

1 answer 1

To intercept both the standard stream and the error stream in bash:

 $ hdfs namenode -format |& less 

Sometimes applications write directly to the terminal ( example ), in such cases you can use screen to intercept the output:

 $ screen -L -- hdfs namenode -format $ mv screenlog.0 result.txt