BASH Shell escape key garbled

Source: Internet
Author: User
Tags hadoop fs

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.