GNU shell utilities - 4. Printing text

Go to the first, previous, next, last section, table of contents.

# 4. Printing text

This section describes commands that display text strings.

## 4.1 `echo`: Print a line of text

`echo` writes each given string to standard output, with a space between each and a newline after the last one. Synopsis:

    echo [option]... [string]...

The program accepts the following options. Also see section 2. Common options.

``-n'`
  Do not output the trailing newline.
``-e'`
  Enable interpretation of the following backslash-escaped characters in each string:
  ``\a'`
    alert (bell)
  ``\b'`
    backspace
  ``\c'`
    suppress trailing newline
  ``\f'`
    form feed
  ``\n'`
    new line
  ``\r'`
    carriage return
  ``\t'`
    horizontal tab
  ``\v'`
    vertical tab
  ``\\'`
    backslash
  ``\nnn'`
    the character whose ASCII code is nnn (octal); if nnn is not a valid octal number, it is printed literally.

## 4.2 `printf`: Format and print data

`printf` does formatted printing of text. Synopsis:

    printf format [argument]...

`printf` prints the format string, interpreting ``%'` directives and ``\'` escapes in the same way as the C `printf` function. The format argument is re-used as necessary to convert all of the given arguments.

`printf` has one additional directive, ``%b'`, which prints its argument string with ``\'` escapes interpreted in the same way as in the format string.

`printf` interprets ``\0ooo'` in format as an octal number (if ooo is 0 to 3 octal digits) specifying a character to print, and ``\xhhh'` as a hexadecimal number (if hhh is 1 to 3 hex digits) specifying a character to print.

An additional escape, ``\c'`, causes `printf` to produce no further output.

The only options are a lone ``--help'` or ``--version'`. See section 2. Common options.

## 4.3 `yes`: Print a string until interrupted

`yes` prints the command line arguments, separated by spaces and followed by a newline, forever until it is killed. If no arguments are given, it prints ``y'` followed by a newline forever until killed.

The only options are a lone ``--help'` or ``--version'`. See section 2. Common options.

Go to the first, previous, next, last section, table of contents.