Читать книгу Linux Bible - Christopher Negus - Страница 214

Remove sections of lines of text (cut)

Оглавление

The cut command can extract fields from a line of text or from files. It is very useful for parsing system configuration files into easy-to-digest chunks. You can specify the field separator you want to use and the fields you want, or you can break up a line based on bytes.

The following example lists all home directories of users on your system. This grep command line pipes a list of regular users from the /etc/passwd file and displays the sixth field (-f6) as delimited by a colon (-d':'). The hyphen at the end tells cut to read from standard input (from the pipe).

 $ grep /home /etc/passwd | cut -d':' -f6 - /home/chris /home/joe

Linux Bible

Подняться наверх