Linux [Electronic resources] نسخه متنی

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

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

Linux [Electronic resources] - نسخه متنی

Janet Valade

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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


Special Characters and Quotes


Shell scripts can take advantage of the special meanings given to certain characters. Useful special characters are:

  • *
    Represents any string of characters in a filename. Used alone, * results in a list of all filenames in the current directory, except filenames that begin with a dot.

  • ?
    Represents a single character in a filename. Using file? would result in a list of filenames containing file1, file3, and file9, but not file10, file20, etc.

  • […]
    A substitution list that contains a set of characters to be matched. For instance, if you used file[xyz], the resulting list would include filex and filey, but not filea or fileq.

  • [!…]
    A substitution list that contains a set of characters to avoid. For instance, the list generated using file[xyz] would include fileb and filew, but not filex or filez.

  • $
    Signals the beginning of a variable name.


You can turn off the meaning of special characters by enclosing them in quotes. Double quotes and single quotes have different effects. Double quotes turn off some special characters, but allow the substitution of variables values. Single quotes turn off all special characters, allowing no variable substitution, as shown by the following commands:

city="San Diego"

echo $city "$city" '$city'
San Diego San Diego $city

As you can see, the single quotes turn off the $ and echo the literal characters between the quotes. You can tell the shell to treat a special character as a literal by preceding it with a back slash, as follows:

echo \$city
$city


    / 357