Top hits - matches a folder name:
Medium hits - matches a file name:
Lesser hits - matches in the text of a file:
CA170 - Introduction to Operating Systemsca170/sample.2.html<input type=radio name='7' value='1' id='7_1' > <label for='7_1' > <tt> grep "^born" * </tt> </label> <br>
<input type=radio name='7' value='2' id='7_2' > <label for='7_2' > <tt> grep "^ born" * </tt> </label> <br>
<input type=radio name='7' value='3' id='7_3' > <label for='7_3' > <tt> grep "^ .born" * </tt> </label> <br>
<input type=radio name='7' value='4' id='7_4' > <label for='7_4' > <tt> grep "^ .*born" * </tt> </label> <br>
<input type=radio name='7' value='5' id='7_5' > <label for='7_5' > <tt> grep "^.born" * </tt> </label> <br>
<input type=radio name='7' value='6' id='7_6' > <label for='7_6' > <tt> grep "born" * </tt> </label> <br>
<input type=radio name='7' value='7' id='7_7' > <label for='7_7' > <tt> grep "^ *born" * </tt> </label> <br>
<input type=radio name='12' value='1' id='12_1' > <label for='12_1' > <tt> grep -i King */act* | wc -l </tt> </label> <br>
<input type=radio name='12' value='2' id='12_2' > <label for='12_2' > <tt> grep -c King */act* | wc -l </tt> </label> <br>
<input type=radio name='12' value='3' id='12_3' > <label for='12_3' > <tt> grep -ic King */act* | wc -l </tt> </label> <br>
<input type=radio name='12' value='4' id='12_4' > <label for='12_4' > <tt> grep -ic King */act* </tt> </label> <br>
<input type=radio name='12' value='5' id='12_5' > <label for='12_5' > <tt> grep -c King */act* </tt> </label> <br>
<input type=radio name='12' value='6' id='12_6' > <label for='12_6' > <tt> grep -i King */act* </tt> </label> <br>
<input type=radio name='12' value='7' id='12_7' > <label for='12_7' > <tt> grep King */act* </tt> </label> <br>
<input type=radio name='12' value='8' id='12_8' > <label for='12_8' > <tt> grep King */act* | wc -l </tt> </label> <br>
<li class=question ca216 ca249 ca651 ca170open > What is this script doing? <p> <tt> grep string file > /dev/null </tt
<input type=radio name='25' value='1' id='25_1' > <label for='25_1' > <tt> grep Scotland ../chap*html </tt> </label> <br>
<input type=radio name='25' value='2' id='25_2' > <label for='25_2' > <tt> grep Scotland chap*html </tt> </label> <br>
<input type=radio name='25' value='3' id='25_3' > <label for='25_3' > <tt> grep Scotland \*chap*html </tt> </label> <br>
<input type=radio name='25' value='4' id='25_4' > <label for='25_4' > <tt> grep Scotland /*chap*html </tt> </label> <br>
<input type=radio name='25' value='5' id='25_5' > <label for='25_5' > <tt> grep Scotland */*/chap*html </tt> </label> <br>
<input type=radio name='25' value='6' id='25_6' > <label for='25_6' > <tt> grep Scotland *chap*html </tt> </label> <br>
<input type=radio name='25' value='7' id='25_7' > <label for='25_7' > <tt> grep Scotland ./chap*html </tt> </label> <br>
<input type=radio name='25' value='8' id='25_8' > <label for='25_8' > <tt> grep Scotland */chap*html </tt> </label> <br>
CA170 - Introduction to Operating Systemsca170/sample.html<li class=question ca216 ca249 ca651 ca170open > What is this script doing? <p> <tt> grep string file > /dev/null </tt
<input type=radio name='2' value='1' id='2_1' > <label for='2_1' > <tt> grep -i King */act* </tt> </label> <br>
<input type=radio name='2' value='2' id='2_2' > <label for='2_2' > <tt> grep -c King */act* | wc -l </tt> </label> <br>
<input type=radio name='2' value='3' id='2_3' > <label for='2_3' > <tt> grep King */act* | wc -l </tt> </label> <br>
<input type=radio name='2' value='4' id='2_4' > <label for='2_4' > <tt> grep -ic King */act* </tt> </label> <br>
<input type=radio name='2' value='5' id='2_5' > <label for='2_5' > <tt> grep -c King */act* </tt> </label> <br>
<input type=radio name='2' value='6' id='2_6' > <label for='2_6' > <tt> grep King */act* </tt> </label> <br>
<input type=radio name='2' value='7' id='2_7' > <label for='2_7' > <tt> grep -i King */act* | wc -l </tt> </label> <br>
<input type=radio name='2' value='8' id='2_8' > <label for='2_8' > <tt> grep -ic King */act* | wc -l </tt> </label> <br>
<input type=radio name='4' value='1' id='4_1' > <label for='4_1' > <tt> grep scotland *html </tt> </label> <br>
<input type=radio name='4' value='2' id='4_2' > <label for='4_2' > <tt> grep -i Scotland *html </tt> </label> <br>
<input type=radio name='4' value='3' id='4_3' > <label for='4_3' > <tt> grep Scotland *html </tt> </label> <br>
<input type=radio name='4' value='4' id='4_4' > <label for='4_4' > <tt> grep -i scotland *html </tt> </label> <br>
<input type=radio name='21' value='1' id='21_1' > <label for='21_1' > <tt> grep Scotland ./chap*html </tt> </label> <br>
<input type=radio name='21' value='2' id='21_2' > <label for='21_2' > <tt> grep Scotland /*chap*html </tt> </label> <br>
<input type=radio name='21' value='3' id='21_3' > <label for='21_3' > <tt> grep Scotland chap*html </tt> </label> <br>
<input type=radio name='21' value='4' id='21_4' > <label for='21_4' > <tt> grep Scotland *chap*html </tt> </label> <br>
<input type=radio name='21' value='5' id='21_5' > <label for='21_5' > <tt> grep Scotland ../chap*html </tt> </label> <br>
<input type=radio name='21' value='6' id='21_6' > <label for='21_6' > <tt> grep Scotland */*/chap*html </tt> </label> <br>
<input type=radio name='21' value='7' id='21_7' > <label for='21_7' > <tt> grep Scotland \*chap*html </tt> </label> <br>
<input type=radio name='21' value='8' id='21_8' > <label for='21_8' > <tt> grep Scotland */chap*html </tt> </label> <br>
Practicalca668/practical.htmland this gets into the "grep" command-line call?
Help on searchhelp.search.html <li> The search works like <A HREF="http://en.wikipedia.org/wiki/Grep">grep</A>,
<li> The search engine works like grep, because it <I>is </I> grep.
and has a grep at the core of it.
with grep at the core,
grep at the core.
How to write a search engine in 9 lines of ShellNotes/CGI/search.engine.htmlgrep -i "$argument" *html */*html | sed -e 's|<|\&lt;|g' | sed -e 's|>|\&gt;|g'
<li> We pipe the result of grep into an ugly-looking
there are HTML tags in the results returned by grep.
or get a recursive grep,
grep -i "$argument" $filespec
grep -i "$argument" $filespec
<tt>grep</tt> finds them.
but there is still a grep at the core.
rather than <tt>grep</tt>-ing them on the spot.
But a <tt>grep</tt> is perfectly fine for a site
Lab - WebNotes/Internet/lab.web.html<pre> find / -maxdepth 3 -type d 2> /dev/null | grep ht </pre>
EmailNotes/Networks/email.htmle.g. I have programs to "grep" local copy of my email,
Lab - 404 PHP handlerNotes/Networks/lab.404.html<pre> grep -i segment filelist </pre>
<li> Collect the grep output using
Make the URL safe for grep
We use "." because it means "any character" in grep.
<li> Search each segment. Collect the return code from grep.
<li> Assume each grep could have multiple matches
PHP search engineNotes/Networks/php.search.html<A HREF="../UNIX/intro.2.html#grep">grep</A>
e.g. Search for <A HREF="https://humphryscomputing.com/search.php?q=grep">grep</A>.
<pre> cd (somedir) ; grep -i (searcharg) */*html </pre>
<li> Collect the grep output in a PHP variable.
<li> Go through the grep output line by line.
What if grep returns tens of thousands of lines? <BR>
Pipe grep to <A HREF="../UNIX/shell.utilities.html#head.tail">head</A>, which collects the first n lines of what is piped into it
<pre> grep string files | head -500 </pre>
<li> The previous will actually <I>terminate </I> grep once 500 is reached.
Binary v. TextNotes/OS/binary.text.html<H3> grep *doc </H3>
grep string *doc
that grep returns.
Q. Can any of these be called from a DOS script like grep?
<tt> grep "\[\[.*\]\]" * </tt>
Using filesNotes/OS/files.user.html sed, grep, ls, cut, etc.
$ ls -l /bin | grep '^l'
$ ls -l /usr/bin | grep '^l'
ProcessesNotes/OS/processes.html<pre> ps -u $USER -f | grep bash </pre>
<pre> ps -Af | grep nano </pre>
humphrys 32374 29859 grep 1
String searchingNotes/String/string.search.html<H1> grep </H1>
<A HREF="http://en.wikipedia.org/wiki/Grep">grep</A>
<A HREF="../Networks/php.search.html"> My search engine based on grep</A>
But how does grep (or other string-finding programs)
<h1> What does grep use? </h1>
grep can't use the standard Boyer-Moore algorithm</A>
because grep allows <A HREF="http://en.wikipedia.org/wiki/Regular_expression">regular expressions</A>
<td> grep "CO.*STING" </td>
<td> grep -i "<img.*src=" </td>
<LI> grep normally uses a <A HREF="http://en.wikipedia.org/wiki/Finite_state_machine">finite automaton</A>
Einstein - cwebNotes/UNIX/einstein.cweb.html<PRE> grep Scotland *html </PRE>
by <A HREF="more.html#pipes.etc">piping </a> the output of grep into
<PRE> grep Scotland *html | sed -e "s|Scotland|Kerry|g" </PRE>
grep Scotland complete.html
Einstein - FlickrNotes/UNIX/einstein.flickr.html<a href="filterbaks.html#egrep">egrep</a>
<pre> egrep 'X|Y' </pre>
<font color=red><b>[wget command]</b></font> | <font color=red><b>[egrep command]</b></font>
<font color=red><b>[wget command]</b></font> | <font color=red><b>[egrep command]</b></font> | <font color=red><b>[tr command]</b>
<font color=red><b>[wget command]</b></font> | <font color=red><b>[egrep command]</b></font> | <font color=red><b>[tr command]</b>
cat $1 | <font color=red><b>[egrep command]</b></font> ....
Einstein - Search engineNotes/UNIX/einstein.gweb.htmlgrep -i "$1" */*html
grep -i "$1" */*html
"<pre>" before the grep
grep -i "$1" */*html
grep -i "$1" */*html | <font color=red><b>[sed command]</b></font>
but grep output is not clickable. It looks like this:
grep -i "$1" */*html | <font color=red><b>[sed command]</b></font> | clickable
See <A HREF="shell.utilities.html#cut.grep.output"> How to use cut to parse grep output</A>.
Sample Shell script - filterbaksNotes/UNIX/filterbaks.html ls -al $* | grep -v "%$" | grep -v "~$" | grep -iv "\.bak$"
grep -v means exclude lines that contain the pattern
$ ls -l *kuwait* | grep -v 'bak'
$ ls -l *kuwait* | grep -v '.bak'
$ ls -l *kuwait* | grep -v '\.bak'
$ ls -l *kuwait* | grep -v '\.bak$'
Make our list of grep's into a separate file, called say "filterbaks":
grep -v "%$" | grep -v "~$" | grep -iv "\.bak$"
<H3> <A name="egrep">egrep </A></H3>
We can do this using the "egrep" program,
which can grep for boolean expressions. <BR>
egrep -iv "%$|~$|\.bak$"
Shell functionsNotes/UNIX/functions.html du | grep '\.$' | cut -f1
ps -Tf | grep -i $1
humphrys 28414 28413 0 12:32:50 pts/5 0:00 grep -i textedit
so we need to strip out killstring itself, and the grep itself.
ps -Tf | grep -i $1 | grep -v $0 | grep -v "grep -i $1" | fn
Introduction to UNIX / Linux (More)Notes/UNIX/intro.2.html<H1> <A name="grep">grep</A></H1>
grep Search for a string in a file or files
grep (string) (file)
grep (string) *html
grep -i (string) (file) Ignore case
grep -v (string) (file) Return lines that do NOT match
Find overloaded pagesNotes/UNIX/lab.overloaded.3.html<li> grep the file for lines with an embedded image.
<li> grep again for embedded images.
<li> Use grep to <I>get rid of</I> lines with 'http'
<li> Use grep to search for JPEGs only.
Lab - ShellNotes/UNIX/lab.shell.htmlIt then searches the page (using grep) for the argument.
Wikify a pageNotes/UNIX/lab.wiki.html<tt> grep '[A-Z][a-z]' </tt>
Lab - xprogNotes/UNIX/lab.xprog.html <LI> <tt> xprog grep </tt> - rejected
More UNIXNotes/UNIX/more.htmlcat file | grep -i dcu | grep -iv computing | sort
cat file | grep -i student > studentlist
cat file | grep -i staff > stafflist
grep string file
grep string < file
cat file | grep string
Linux Quiz 3Notes/UNIX/quiz.3.html<H3> grep </H3>
<li> Use "grep" to find all lines where "Ireland" appears in the plays.
Use "grep" and "wc".
Use grep of the "complete.html" with <B>a certain option</B> to just list the files that have a match.
Run a grep and then pipe the result into more greps with <B>a certain option</B>.
As above, see options for grep.
See options for grep.
<H3> grep of "test suite" </H3>
Linux Quiz BNotes/UNIX/quiz.b.html(Use either "grep" or "wc".)
More on ShellNotes/UNIX/shell.more.html grep -i "http:.*dcu.ie" |
e.g. grep (switches) (string) file1 ... filen
e.g. quiet grep:
grep > /dev/null
though grep may have -q (quiet) option anyway
grep ' file syntax error (why?)
grep "'" file surround with quotes and it works
grep '"' file to search for the double quote itself
grep string *
# grep does not understand *
# but that's fine because grep does not actually RECEIVE *
# the shell EXPANDS * to a list of files and passes these to grep
# so grep actually receives:
grep string f1 f2 .. fn
Sample Shell programsNotes/UNIX/shell.sample.html<li> grep (ignoring case) the argument in all the Shakespeare files
<li> check the return code of grep
Shell utilitiesNotes/UNIX/shell.utilities.html<A NAME="grep">grep</A>
grep search for a string
grep string file
(output of prog) | grep string | grep otherstring
<LI><A HREF="http://en.wikipedia.org/wiki/Grep">grep</A>
<li> <A HREF="http://linux.die.net/man/1/grep">man grep</A>
<li> grep is <B>Substring-oriented</B> (will match inside a word).
<tt> grep -w </tt>
<li> grep is <B>Line-oriented</B> (will print whole line that matches).<BR>
Not always good: Hit we want may spread across multiple lines, so grep won't find it.
<li> Recursive grep:
<tt> grep -r string . </tt>
<tt> grep -r --include="*html" string . </tt>
Use <A HREF="http://linux.die.net/man/1/egrep">egrep </A>
egrep -o ".{0,40}string.{0,40}" file
grep " *" 1 or more spaces
grep "\." the '.' character itself
grep '\$' works (searches for the "$" char instead of end-of-line)
grep "\$" fails (double quote treatment of $ is different to single quote treatment of $)
grep "\\$" works
<h1><A NAME="cut.grep.output"> How to use cut to parse grep output</A></h1>
In grep output, extract the 1st <B>field</B>, with delimiter ":"
grep string *html | cut -f1 -d':'
grep string *html | cut -f2- -d':'
grep -i $1 *html |
grep -l '\015' */*html
LC_ALL=C grep -P "[^\x00-\x7E]" */*html
# if you grep a file with non 7 bit chars you may get a warning like:
grep: file.html: binary file matches
grep string files | head -100
<pre> grep string files | head -100 </pre>
When head gets the first 100 lines, <I>the pipe closes</I> and grep terminates. <BR>
As opposed to: Doing the entire grep and <I>then </I> taking the first 100. <br>
set | grep -i random
set | grep -i random
Windows command lineNotes/UNIX/windows.cmd.html<li> <A HREF="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find">find </A> (like grep)