Learning the bash Shell 2nd Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Learning the bash Shell 2nd Edition [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید

7.2 String I/O

Now we'll zoom back in to the string I/O level and examine the echo and read statements, which give the shell I/O capabilities that are more analogous to those of conventional programming languages.

7.2.1 echo

As we've seen countless times in this book, echo simply prints its arguments to standard output. Now we'll explore the command in greater detail.

7.2.1.1 Options to echo

echo accepts a few dash options, listed in Table 7.2.

Table 7.2. echo Options

Option

Function

-e

Turns on the interpretation of backslash-escaped characters

-E

Turns off the interpretation of backslash-escaped character on systems where this mode is the default

-n

Omit the final newline (same as the \c escape sequence)

7.2.1.2 echo escape sequences

echo accepts a number of escape sequences that start with a backslash. [2]These are similar to the escape sequences recognized by echo and the C language; they are listed in Table 7.3.

[2] You must use a double backslash if you don't surround the string that contains them with quotes; otherwise, the shell itself "steals" a backslash before passing the arguments to echo.

These sequences exhibit fairly predictable behavior, except for \f: on some displays, it causes a screen clear, while on others it causes a line feed. It ejects the page on most printers. \v is somewhat obsolete; it usually causes a line feed.

Table 7.3. echo Escape Sequences

Sequence

Character Printed

\a

ALERT or CTRL-G (bell)

\b

BACKSPACE or CTRL-H

\c

Omit final NEWLINE

\E

Escape charactera

\f

FORMFEED or CTRL-L

\n

NEWLINE (not at end of command) or CTRL-J

\r

RETURN (ENTER) or CTRL-M

\t

TAB or CTRL-I

\v

VERTICAL TAB or CTRL-K

\n

ASCII character with octal (base-8) value n, where n is 1 to 3 digits

\\

Single backslash

[3]

/ 104