

For example, this command searches for iana only in the last 10 lines of 's source code, instead of searching the whole page: $ curl | tail | grep iana One is helping to narrow grep's scope by searching through only the results of another process. Here’s an example: $ grep BSD example.txtĪnother common way to use grep is with a pipe, making it a sort of filter.

The canonical use of grep is searching for a precise string of characters in some greater body of text, and returning the line or lines containing successful matches.
Grep regex for number of characters windows#
GNU grep is available from OpenCSW.Īnd finally, you can get grep and many more commands on Windows by installing the open source Cygwin package, which provides a vast collection of GNU and open source tools.

Grep regex for number of characters code#
Since then, the grep command’s code has been written and rewritten by several different programmers, but its name has persisted. (This tool received wide release only because Thompson's department head, Doug McIlroy, asked for a tool “to look for stuff” in files.) The grep command, which is an initialism for global regular expression print, started its life as a personal utility script on the computer of the co-creator of UNIX, Ken Thompson. If you are a sysadmin or programmer and find yourself obsessively dipping into streams of text on a POSIX system, then you have probably either encountered grep, or come across a time you wished you could use this command. Most people would be disappointed to learn that sysadmins and code monkeys more often poke at streams of text in hopes of getting the right response. Their goal? To reach into the virtual reality of the Internet, gathering the binary forces of code into the applications and infrastructure we all use today. Most people imagine that system administrators and programmers fiddle with knobs and diodes.
