echo(1) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

echo(1)

echo(1)                          User Commands                         echo(1)



NAME
       echo - echo arguments

SYNOPSIS
       /usr/bin/echo [string]...

DESCRIPTION
       The  echo  utility writes its arguments, separated by BLANKs and termi‐
       nated by a NEWLINE, to the standard output. If there are no  arguments,
       only the NEWLINE character is written.


       echo  is useful for producing diagnostics in command files, for sending
       known data into a pipe, and for displaying the contents of  environment
       variables.


       The  C shell, the Korn shell, and the Bourne shell all have echo built-
       in commands, which, by default, is invoked if the user calls echo with‐
       out  a  full  pathname. See shell_builtins(1). sh's echo, ksh88's echo,
       ksh's echo, and /usr/bin/echo understand the backslashed escape charac‐
       ters, except that sh's echo does not understand \a as the alert charac‐
       ter. In addition, ksh88's and ksh's echo does not have  an  -n  option.
       csh's  echo  and  /usr/ucb/echo  (which existed in previous releases of
       Solaris), on the other hand, have an -n option, but do  not  understand
       the  backslashed  escape  characters.  sh  and  ksh88 determine whether
       /usr/ucb/echo is found first in the PATH and, if  so,  they  adapt  the
       behavior   of  the  echo  builtin  to  match  the  BSD  environment  of
       /usr/ucb/echo.

OPERANDS
       The following operand is supported:

       string    A string to be written to standard output. If any operand  is
                 "-n", it is treated as a string, not an option. The following
                 character sequences is recognized within  any  of  the  argu‐
                 ments:

                 \a      Alert character.


                 \b      Backspace.


                 \c      Print  line without newline. All characters following
                         the \c in the argument are ignored.


                 \f      Form feed.


                 \n      Newline.


                 \r      Carriage return.


                 \t      Tab.


                 \v      Vertical tab.


                 \\      Backslash.


                 \0n     Where n is the 8-bit character whose  ASCII  code  is
                         the  1-, 2- or 3-digit octal number representing that
                         character.



USAGE
       Portable applications should not use -n  (as  the  first  argument)  or
       escape sequences.


       The printf(1) utility can be used portably to emulate any of the tradi‐
       tional behaviors of the echo utility as follows:

           o      The Oracle Solaris 11.4 /usr/bin/echo is equivalent to:

                    printf "%b\n" "$*"



           o      BSD behavior of echo is equivalent to:

                    if [ "X$1" = "X-n" ]

                    then

                            shift

                            printf "%s" "$*"

                    else

                            printf "%s\n" "$*"

                    fi




       New applications are encouraged to use printf instead of echo.

EXAMPLES
       Example 1 Finding how far below root your current directory is located



       You can use echo to determine how many subdirectories  below  the  root
       directory (/) is your current directory, as follows:


           o      Echo your current-working-directory's full pathname.


           o      Pipe  the output through tr to translate the path's embedded
                  slash-characters into space-characters.


           o      Pipe that output through wc  -w for a count of the names  in
                  your path.

                    example% /usr/bin/echo $PWD | tr '/' ' ' | wc -w





       See tr(1) and wc(1) for their functionality.


       Below are the different flavors for echoing a string without a NEWLINE:

       Example 2 /usr/bin/echo


         example% /usr/bin/echo "$USER's current directory is $PWD\c"


       Example 3 sh/ksh88 shells


         example$ echo "$USER's current directory is $PWD\c"


       Example 4 csh shell


         example% echo -n "$USER's current directory is $PWD"


       Example 5 /usr/ucb/echo


         example% /usr/ucb/echo -n "$USER's current directory is $PWD"


ENVIRONMENT VARIABLES
       See  environ(7) for descriptions of the following environment variables
       that affect the execution of uname:  LANG,  LC_ALL,  LC_CTYPE,  LC_MES‐
       SAGES, and NLSPATH.

EXIT STATUS
       The following error values are returned:

       0     Successful completion.


       >0    An error occurred.


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ Availabilitysystem/core-os  _  CSIEnabled  _  Interface
       StabilityCommitted _ StandardSee standards(7).


SEE ALSO
       ksh(1),   printf(1),   shell_builtins(1),   tr(1),   wc(1),   ascii(7),
       attributes(7), environ(7), standards(7)

NOTES
       When representing an 8-bit character by  using  the  escape  convention
       \0n, the n must always be preceded by the digit zero (0).


       For  example, typing: echo 'WARNING:\07' prints the phrase WARNING: and
       sounds the "bell" on your terminal.  The  use  of  single  (or  double)
       quotes  (or  two  backslashes) is required to protect the "\" that pre‐
       cedes the "07".


       Following the \0, up to three digits are used in constructing the octal
       output  character.  If,  following the \0n, you want to echo additional
       digits that are not part of the octal representation, you must use  the
       full  3-digit  n. For example, if you want to echo "ESC 7" you must use
       the three digits "033" rather than just the two digits "33"  after  the
       \0.

         2 digits         Incorrect:      echo "\0337" | od -xc
                          produces:       df0a                     (hex)
                                          337                      (ascii)
         3 digits         Correct:        echo "\00337" | od -xc
                          produces:       lb37 0a00                (hex)
                                          033 7                    (ascii)



       For the octal equivalents of each character, see ascii(7).


       In previous releases of Solaris, there was a /usr/ucb/echo command that
       had slightly different behavior from the echo command  described  here.
       /usr/ucb/echo  did  not support backslash escapes and /usr/ucb/echo had
       an -n option that the echo described here does not have. The -n option,
       which  ensures that a newline character is not added to the output, can
       be found with /usr/gnu/bin/echo.



Oracle Solaris 11.4               11 May 2021                          echo(1)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3