他のシェルで「echo -e」エスケープシーケンスを使用する

他のシェルで「echo -e」エスケープシーケンスを使用する

Linuxのシェルにあるコマンドに対して-eこのフラグが存在しないようです。echoこれはちょうど混乱した設定ですか、それとも「正常」ですか?

たとえば、いくつかのコードは次のようになります。

#!/bin/sh
echo -e "\e[3;12r\e[3H"

印刷:

-e \e[3;12r\e[3H

これは以前に働きました!stty一部のコマンドで問題が発生したため、動作しなくなったようです。誰かが私がsh実際にbash

ベストアンサー1

sh代わりに使用したため、bashコマンドechoshオプションはありません-eshマンページから:

echo [-n] args...
            Print the arguments on the standard output, separated by spaces.
            Unless the -n option is present, a newline is output following the
            arguments.

またそうではありません\e

        If any of the following sequences of characters is encountered
        during output, the sequence is not output.  Instead, the specified
        action is performed:

        \b      A backspace character is output.

        \c      Subsequent output is suppressed.  This is normally used at
                the end of the last argument to suppress the trailing new‐
                line that echo would otherwise output.

        \f      Output a form feed.

        \n      Output a newline character.

        \r      Output a carriage return.

        \t      Output a (horizontal) tab character.

        \v      Output a vertical tab.

        \0digits
                Output the character whose value is given by zero to three
                octal digits.  If there are zero digits, a nul character
                is output.

        \\      Output a backslash.

        All other backslash sequences elicit undefined behaviour.

おすすめ記事