Команды с использованием конвейера

Адам Гайд, “Piping hot commands ”, public translation into Russian from English More about this translation.

See also 43 similar translations

Translate into another language.

Participants

mindoff382 points
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated
1 2 3 4

Piping hot commands

Команды с использованием конвейера

History of edits (Latest: mindoff 4 months ago) §

Pipes let programs work together by connecting the output from one to be the input for another. Pipes are built using a vertical bar (|) as the pipe symbol.

Конвейер (pipe) позволяет работать программам вместе, подключая вывод одной программы ко входным данным другой. Конвейер делается с помощью вертикальной черты (|)

History of edits (Latest: mindoff 4 months ago) §

Say you help your eccentric Aunt Hortense manage her private book collection. You have a file named books containing a list of her holdings, one per line, in the format 'author:title', something like this:

К примеру, Вы хотите помочь эксцентричной тёте Гартензии управлять своей частной коллекцией книг. У Вас есть файл с названиями книг, каждая строка которого имеет вид 'Автор:Заголовок', что-то вроде этого:

History of edits (Latest: mindoff 4 months ago) §

$ cat books

$ cat books

History of edits (Latest: mindoff 4 months ago) §

Carroll, Lewis:Through the Looking-Glass

Carroll, Lewis:Through the Looking-Glass

History of edits (Latest: mindoff 4 months ago) §

Shakespeare, William:Hamlet

Shakespeare, William:Hamlet

History of edits (Latest: mindoff 4 months ago) §

Bartlett, John:Familiar Quotations

Bartlett, John:Familiar Quotations

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart:On Nature

Mill, John Stuart:On Nature

History of edits (Latest: mindoff 4 months ago) §

London, Jack:John Barleycorn

London, Jack:John Barleycorn

History of edits (Latest: mindoff 4 months ago) §

Bunyan, John:Pilgrim's Progress, The

Bunyan, John:Pilgrim's Progress, The

History of edits (Latest: mindoff 4 months ago) §

Defoe, Daniel:Robinson Crusoe

Defoe, Daniel:Robinson Crusoe

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart:System of Logic, A

Mill, John Stuart:System of Logic, A

History of edits (Latest: mindoff 4 months ago) §

Milton, John:Paradise Lost

Milton, John:Paradise Lost

History of edits (Latest: mindoff 4 months ago) §

Johnson, Samuel:Lives of the Poets

Johnson, Samuel:Lives of the Poets

History of edits (Latest: mindoff 4 months ago) §

Shakespeare, William:Julius Caesar

Shakespeare, William:Julius Caesar

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart:On Liberty

Mill, John Stuart:On Liberty

History of edits (Latest: mindoff 4 months ago) §

Bunyan, John:Saved by Grace

Bunyan, John:Saved by Grace

History of edits (Latest: mindoff 4 months ago) §

This is somewhat untidy, as they are in no particular order. But we can use the sort command to straighten that out:

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

History of edits (Latest: mindoff 4 months ago) §

$ sort books

$ sort books

History of edits (Latest: mindoff 4 months ago) §

Bartlett, John:Familiar Quotations

Bartlett, John:Familiar Quotations

History of edits (Latest: mindoff 4 months ago) §

Bunyan, John:Pilgrim's Progress, The

Bunyan, John:Pilgrim's Progress, The

History of edits (Latest: mindoff 4 months ago) §

Bunyan, John:Saved by Grace

Bunyan, John:Saved by Grace

History of edits (Latest: mindoff 4 months ago) §

Carroll, Lewis:Through the Looking-Glass

Carroll, Lewis:Through the Looking-Glass

History of edits (Latest: mindoff 4 months ago) §

Defoe, Daniel:Robinson Crusoe

Defoe, Daniel:Robinson Crusoe

History of edits (Latest: mindoff 4 months ago) §

Johnson, Samuel:Lives of the Poets

Johnson, Samuel:Lives of the Poets

History of edits (Latest: mindoff 4 months ago) §

London, Jack:John Barleycorn

London, Jack:John Barleycorn

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart:On Liberty

Mill, John Stuart:On Liberty

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart:On Nature

Mill, John Stuart:On Nature

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart:System of Logic, A

Mill, John Stuart:System of Logic, A

History of edits (Latest: mindoff 4 months ago) §

Milton, John:Paradise Lost

Milton, John:Paradise Lost

History of edits (Latest: mindoff 4 months ago) §

Shakespeare, William:Hamlet

Shakespeare, William:Hamlet

History of edits (Latest: mindoff 4 months ago) §

Shakespeare, William:Julius Caesar

Shakespeare, William:Julius Caesar

History of edits (Latest: mindoff 4 months ago) §

Ah, now you have a list nicely sorted by author. How about getting a list just of authors, without titles? You can do that with the cut command:

Теперь у Вас есть список, отстортированый по автору. Как насчет того, чтобы получить список только с авторами, без заголовков? Вы можете это сделать с помощью команды cut:

History of edits (Latest: mindoff 4 months ago) §

$ cut -d: -f1 books

$ cut -d: -f1 books

History of edits (Latest: mindoff 4 months ago) §

Carroll, Lewis

Carroll, Lewis

History of edits (Latest: mindoff 4 months ago) §

Shakespeare, William

Shakespeare, William

History of edits (Latest: mindoff 4 months ago) §

Bartlett, John

Bartlett, John

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart

Mill, John Stuart

History of edits (Latest: mindoff 4 months ago) §

London, Jack

London, Jack

History of edits (Latest: mindoff 4 months ago) §

Bunyan, John

Bunyan, John

History of edits (Latest: mindoff 4 months ago) §

Defoe, Daniel

Defoe, Daniel

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart

Mill, John Stuart

History of edits (Latest: mindoff 4 months ago) §

Milton, John

Milton, John

History of edits (Latest: mindoff 4 months ago) §

Johnson, Samuel

Johnson, Samuel

History of edits (Latest: mindoff 4 months ago) §

Shakespeare, William

Shakespeare, William

History of edits (Latest: mindoff 4 months ago) §

Mill, John Stuart

Mill, John Stuart

History of edits (Latest: mindoff 4 months ago) §

Bunyan, John

Bunyan, John

History of edits (Latest: mindoff 4 months ago) §

A little explanation here. The -d option chose a colon as the delimiter (separator). This tells cut to break up each line wherever a delimiter appears, and each separate part of the line is called a field. In our format, the author's name appears as the first field, so we have put a 1 with the -f option to tell cut that we want to see just that field.

Pages: ← previous Ctrl next next untranslated
1 2 3 4