From: http://share.blog.51cto.com/278008/583382
I wrote a very simple script to upload a file to a directory of HDFS in hadoop. When you enter the file name or directory name, an error occurs sometimes and you need to delete the incorrect input. However, when you press the backspace key, garbled characters (^ h) are displayed. Each time you press the backspace key, a ^ h occurs.
Search for online materials and refer to the following webpage to find a solution:
First, press and hold the ctrl key when you press the return key;
Second, modify the. bash_profile file:
A) under Bash: $ stty erase ^?
Or set stty erase ^? Add to. bash_profile.
B) under CSH: $ stty erase ^ h
Or add stty erase ^ h to. cshrc.
Stty erase "^ h"
I tried both methods. The first method is correct, but the problem occurred when I tried the second method, as shown below:
My default shell is Bash, and bash is also called in the script. I write $ stty erase ^? In. bash_profile ?, But it has no effect at all!
Therefore, it is effective to write stty erase "^ h ".
.
Later, I carefully observed that ^ h appeared when I typed the backspace key in bash, and this character should be something in CSH! I don't know how this strange phenomenon came about. Script:
#! /Bin/bash #2011-06-07 by Qinshan. Li # echo-n "type your path:" read path ~ /Hadoop-0.20.2-CDH3B4/bin/hadoop FS-mkdir $ {path} if ["$? "=" 0 "]; Then ECHO-e" $ (Date "+ % t"): create directory successfully! "Else echo-e" $ (Date "+ % t"): create directory failed! "Fi echo-n" type your file to upload: "Read File ~ /Hadoop-0.20.2-CDH3B4/bin/hadoop FS-movefromlocal $ {file }$ {path} if ["$? "=" 0 "]; Then ECHO-e" $ (Date "+ % t"): uploaded successfully! "Else echo-e" $ (Date "+ % t"): uploaded failed! "Fi