Документ взят из кэша поисковой машины. Адрес оригинального документа : http://comet.sai.msu.ru/UNIXhelp/utilities2/grep3.1.html
Дата изменения: Fri Jan 17 12:43:26 1997
Дата индексирования: Tue Oct 2 02:08:08 2012
Кодировка:

Поисковые слова: extremely red object
Examples of using regular expressions

Examples of using regular expressions

To search using enclosed characters:

   grep -n '[dD]on't' tasks

This uses a regular expression to find and display each line in the file tasks that contains the pattern don't or Don't. The line number for each line is also displayed.


To turn off the meaning of a special character:

   grep '^\\$' money

This lists all the lines in the file money that begin with a $ (dollar) sign. This character is preceded by a \\(backslash) to remove its meaning as a special character.


To search from the beginning of a line:

   ls -l | grep '^d........x'

This lists all the directories in the current directory for which other users have execute permission.


To search for lines ending in a particular pattern:

   ls -l | grep '[^.xdh]$'

This lists all the files and directories in the current directory which do not end in .xdh.


[Home] [Search] [Index]