LinuxCommandLibrary

ec.1s

Evaluate expressions and perform arithmetic

SYNOPSIS

ec [options] [string ...]

PARAMETERS

-a
    Expand all specified octal values to their ASCII character equivalent.

-b
    Process backslash escape sequences explicitly.

-e
    Enable interpretation of backslash escapes (similar to modern `echo -e`).

-n
    Suppress the trailing newline character from the output.

-p
    Print the processed strings to standard output.

-r
    Process strings in raw mode, disabling certain interpretations.

-s
    Strip multiple blank characters into a single space.

-t
    Expand tab characters encountered in the string.

-v
    Expand vertical tab characters.

DESCRIPTION

The ec command, primarily found on older Unix-like systems such as SCO OpenServer and XENIX, is designed to process and expand escape character sequences within provided strings. It functions similarly to the -e option of the modern echo command, interpreting sequences like \n for newline, \t for tab, \b for backspace, and \0nnn for octal character representations. Its main purpose was to enable the display of special characters and formatting through the shell, especially in environments where the default echo command did not support such interpretations. This utility was crucial for script portability and text manipulation before the widespread adoption of standardized escape sequence handling in shell built-ins.

CAVEATS

The ec command is primarily found on older Unix-like systems (e.g., SCO OpenServer, XENIX) and is generally not available on modern Linux distributions, where its functionality is typically handled by echo -e or printf. Its behavior might vary slightly across different legacy systems.

SUPPORTED ESCAPE SEQUENCES

ec supports various escape sequences including \a (alert/bell), \b (backspace), \c (suppress newline), \f (form feed), \n (newline), \r (carriage return), \t (horizontal tab), \v (vertical tab), \\ (literal backslash), and \0nnn (character specified by its octal value nnn).

HISTORY

The ec command originates from early Unix systems, specifically appearing in distributions like SCO OpenServer and XENIX. It served as a standalone utility for processing escape sequences before the echo command gained its -e option, which standardized the interpretation of such sequences directly within the shell built-in. Its existence highlights an evolutionary step in shell scripting capabilities, moving from dedicated external commands to more integrated shell features.

SEE ALSO

echo(1), printf(1)

Copied to clipboard