Thursday, April 14, 2011

bash: how do I write non ascii chars using echo?

Is there an escape sequence, such as \012 or something like that?

I want to append on ascii chars to a file using echo ?? >> file

From stackoverflow
  • Use

    echo -e "\012"
    
  • Duplicate of this question.

    vartec : Well, not exactly, this 7-bit ASCII control code '\n', not unicode.
  • In the DOS command line enter EDIT, then to insert control characters use CTRL+P followed by the control character required.

    For example

    echo Ctrl-P ALT+013 > file
    
  • If you care about portability, you'll drop echo and use printf(1):

    printf '\012'
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.