Date: Mon, 26 Jun 2000 23:10:21 +0100 From: Ben Smithurst <ben@scientia.demon.co.uk> To: Mark Ovens <mark@ukug.uk.freebsd.org> Cc: questions@freebsd.org Subject: Re: Question about echo(1) Message-ID: <20000626231021.H57917@strontium.scientia.demon.co.uk> In-Reply-To: <20000626222417.J232@parish> References: <20000626222417.J232@parish>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Mark Ovens wrote:
> I found in a script ``echo -e .....''. The echo(1) manpage doesn't
> list this as an option. builtin(1) lists echo as both external and
> internal to both csh(1) and sh(1) but the sh(1) manpage doesn't
> mention echo.
>
> Under csh(1) ``echo -e'' prints ``-e'', but under sh(1):
>
> parish# sh
> # echo
>
> # echo -e
>
> # echo foobar
> foobar
> # echo -e foobar
> foobar
> #
>
> So, what does ``-e'' do under sh(1)?
It might be a bash thing. From "man bash":
echo [-neE] [arg ...]
Output the args, separated by spaces, followed by a
newline. The return status is always 0. If -n is
specified, the trailing newline is suppressed. If
the -e option is given, interpretation of the fol-
lowing backslash-escaped characters is enabled.
The -E option disables the interpretation of these
escape characters, even on systems where they are
interpreted by default. echo does not interpret --
to mean the end of options. echo interprets the
following escape sequences:
\a alert (bell)
\b backspace
\c suppress trailing newline
\e an escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\nnn the character whose ASCII code is the octal
value nnn (one to three digits)
\xnnn the character whose ASCII code is the hex-
adecimal value nnn (one to three digits)
in bash,
bash-2.03$ echo -e "\a"
(I heard a beep at this point...)
bash-2.03$ echo "\a"
\a
but in sh they both just print "\a".
--
Ben Smithurst / ben@scientia.demon.co.uk / PGP: 0x99392F7D
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: ETjK0WSUbD7h7fElBiNA4ikHc9V72n1R
iQCVAwUBOVfUzSsPVtiZOS99AQGlWgQAo3gltUJXIxAoF6JaNXD8MssIxxNyw+eK
a271F9a1V2trv1X2bZqORqTfXrxyVjchmZ8+j5X49GaS6020aGFFbQGPI8r5YECL
IQlHiV78QJdnTlBLZ7g9vbd/b18ZOHFwjOn1IfR7S5JScAUCRpLC3EudK6MNPEc9
6eQXI2dEYMA=
=xWha
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000626231021.H57917>
