Европейский Университет в Санкт-Петербурге
Опубликован: 04.07.2008 | Доступ: свободный | Студентов: 1321 / 264 | Оценка: 4.34 / 3.65 | Длительность: 21:13:00
Лекция 10:

Получение дополнительной информации

< Лекция 9 || Лекция 10: 123 || Лекция 11 >

Руководство по Solaris

Руководство по Solaris разделено на несколько разделов. Номер раздела может быть цифрой, за которой, возможно, следует одна или несколько букв, в зависимости от названия раздела. Кроме этого, раздел может называться одним словом, например, local, new или public. Каждая страница руководства представлена только в одном разделе. Однако, в разных разделах могут быть таблицы с одним заголовком, например, passwd (1) и passwd (4), рассказывающие о связанных понятиях, файлах и программах. Так, страница passwd в разделе 1 рассказывает о программе passwd, а страница passwd в разделе 4 рассказывает о формате и назначении файла /etc/passwd. Разделы man делятся на подразделы, например, в разделе 1 есть подразделы 1m, 1b, 1c, 1f, 1s. Объяснение того, какие страницы содержатся в каждом из подразделов, дано в man intro. Страница intro есть в каждом разделе, от intro (1) до intro (9). Это – введение в справочный раздел. Если потребуется более подробное описание того, что содержится в нем, можно вызвать

man –s N intro

Поставьте вместо N номер того раздела, который вас заинтересовал (от 1 до 9).

В таблице 10.1 перечислены основные разделы справочного руководства по Solaris.

Многие системы UNIX содержат раздел 8, в котором находятся описания программ обслуживания системы; но в Solaris все страницы, описывающие программы, собраны в разделе 1. Поэтому раздела 8 в руководстве по Solaris нет.

Таблица 10.1. Основные разделы справочного руководства по Solaris
1 Основные команды
2 Системные вызовы и коды ошибок
3 Библиотеки С
4 Устройства и драйверы устройств
5 Форматы файлов
6 Инструкции к играм и демо-версиям программ
7 Специальные файлы, описания протоколов, драйверы и интерфейсы к ним
9 Интерфейсы системных функций ядра

В страницах руководства номер раздела указывается в круглых скобках после команды, например halt(1M). Такая запись представляет как имя команды (halt), так и страницу руководства (1M). При поиске подробной информации о чем-либо нужно обратиться к соответствующей странице документации. (Просмотреть страницу документации можно с помощью команды man(1).)

Страница документации есть почти по каждой теме. Например, для просмотра страницы руководства по программе поиска подстрок grep нужно ввести следующую команду:

#man grep

В ответ система выдаст следующую информацию:

Name
grep - search a file for a pattern
Synopsis
/usr/bin/grep [-bchilnsvw] limited-regular-expression [filename...]
/usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvwx] -e pattern_
list... [-f pattern_file]... [file...]
/usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvwx] [-e pattern_
list...] -f pattern_file... [file...]
/usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvwx] pattern
[file...]
Description
The grep utility searches text files for a pattern and prints all
lines that contain that pattern. It uses a compact non-deterministic
algorithm.
Be careful using the characters $, *, [, ^, |, (, ), and \ in the
pattern_list because they are also meaningful to the shell. It is
safest to enclose the entire pattern_list in single quotes `... `.
If no files are specified, grep assumes standard input. Normally, each
line found is copied to standard output. The file name is printed
before each line found if there is more than one input file.
/usr/bin/grep
The /usr/bin/grep utility uses limited regular expressions like those
described on the regexp(5) manual page to match the patterns.
/usr/xpg4/bin/grep
The options -E and -F affect the way /usr/xpg4/bin/grep interprets
pattern_list. If -E is specified, /usr/xpg4/bin/grep interprets
pattern_list as a full regular expression (see -E for description). If
-F is specified, grep interprets pattern_list as a fixed string. If
neither are specified, grep interprets pattern_list as a basic regular
expression as described on regex(5) manual page.

Options
The following options are supported for both /usr/bin/grep and /usr/
xpg4/bin/grep:
-b
Precede each line by the block number on which it was found. This can
be useful in locating block numbers by context (first block is 0).
-c
Print only a count of the lines that contain the pattern.
-h
Prevents the name of the file containing the matching line from being
appended to that line. Used when searching multiple files.
-i
Large File Behavior

See largefile(5) for the description of the behavior of grep when
encountering files greater than or equal to 2 Gbyte ( 2 **31 bytes).

Examples
Example 1: Finding all uses of a word
To find all uses of the word "Posix" (in any case) in the file text.
mm, and write with line numbers:
example% /usr/bin/grep -i -n posix text.mm
Example 2: Finding all empty lines
To find all empty lines in the standard input:
example% /usr/bin/grep ^$
or
example% /usr/bin/grep -v .
Example 3: Finding lines containing strings
Both of the following commands print all lines containing strings abc
or def or both:
example% /usr/xpg4/bin/grep -E `abc def’
example% /usr/xpg4/bin/grep -F `abc def’
Example 4: Finding lines with matching strings
Both of the following commands print all lines matching exactly abc or
def:
example% /usr/xpg4/bin/grep -E `^abc$ ^def$’
example% /usr/xpg4/bin/grep -F -x `abc def’
Environment Variables
See environ(5) for descriptions of the following environment variables
that affect the execution of grep: LC_COLLATE, LC_CTYPE, LC_MESSAGES,
and NLSPATH.
Exit Status
The following exit values are returned:
0
One or more matches were found.
1
No matches were found.
2
Syntax errors or inaccessible files (even if matches were found).
See Also
egrep(1) , fgrep(1) , sed(1) , sh(1) , attributes(5) , environ(5) ,
largefile(5) , regex(5) , regexp(5) , XPG4(5)
Notes
/usr/bin/grep
Lines are limited only by the size of the available virtual memory. If
there is a line with embedded nulls, grep will only match up to the
first null; if it matches, it will print the entire line.
/usr/xpg4/bin/grep
The results are unspecified if input files contain lines longer than
LINE_MAX bytes or contain binary data. LINE_MAX is defined in /usr/
include/limits.h.

Вывод man grep сильно сокращен, так как здесь нам требуется не детальный обзор grep, а общий вид какой-нибудь страницы руководства.

Первый блок информации, представленный в верхней строке, сообщает заголовок страницы руководства и номер раздела.

Обратите внимание на то, что в Solaris поддерживается две версии grep – классическая ( /usr/bin/grep ) и расширенная ( /usr/xpg4/bin/grep ).

Ниже рассмотрены элементы страницы руководства, которые могут помочь вам не только разобраться в предмете, но и получить направление для нового поиска.

< Лекция 9 || Лекция 10: 123 || Лекция 11 >
Александр Тагильцев
Александр Тагильцев

Где проводится профессиональная переподготовка "Системное администрирование Windows"? Что-то я не совсем понял как проводится обучение.