<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2Fgrep</id>
	<title>Linux/grep - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2Fgrep"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/grep&amp;action=history"/>
	<updated>2026-05-03T21:33:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Linux/grep&amp;diff=8268&amp;oldid=prev</id>
		<title>Kenneth: /* OR */</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/grep&amp;diff=8268&amp;oldid=prev"/>
		<updated>2025-01-03T08:05:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;OR&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:05, 3 January 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l23&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ref: [https://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ref: [https://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== show filename and line number ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Useful if you feed in many files to grep (eg find . -type f -exec grep -H -n PATTERN {} \; )&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; grep -H -n [pattern] [FILE] ...&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  find . -type f -exec grep -H -n PATTERN {} \;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Show Non ASCII Characters ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Show Non ASCII Characters ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key aznot:diff:1.41:old-6134:rev-8268:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
	<entry>
		<id>https://aznot.com/index.php?title=Linux/grep&amp;diff=6134&amp;oldid=prev</id>
		<title>Kenneth at 23:26, 23 November 2022</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/grep&amp;diff=6134&amp;oldid=prev"/>
		<updated>2022-11-23T23:26:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== grep ==&lt;br /&gt;
&lt;br /&gt;
Print only matching:&lt;br /&gt;
 grep -o &amp;#039;[PATTERN]&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Get IP addresses:&lt;br /&gt;
 ifconfig | grep -o &amp;#039;[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 IP=`curl -s ip.oeey.com`&lt;br /&gt;
 echo &amp;quot;$IP&amp;quot; | grep -o &amp;#039;^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$&amp;#039;&lt;br /&gt;
 echo $?  # 0 on success, 1 on fail&lt;br /&gt;
&lt;br /&gt;
Ignore fully commented lines:&lt;br /&gt;
 cat [file] | grep -v &amp;quot;^\s*#&amp;quot; | grep -v &amp;quot;^$&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== OR ==&lt;br /&gt;
&lt;br /&gt;
 grep -e pattern1 -e pattern2 filename&lt;br /&gt;
&lt;br /&gt;
 grep -E &amp;quot;pattern1|pattern2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 grep &amp;quot;pattern1\|pattern2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ref: [https://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/]&lt;br /&gt;
&lt;br /&gt;
== Show Non ASCII Characters ==&lt;br /&gt;
&lt;br /&gt;
 grep -a --color=&amp;#039;auto&amp;#039; -P -n &amp;quot;[\x80-\xFF]&amp;quot; file.xml&lt;br /&gt;
 grep -a --color=&amp;#039;auto&amp;#039; -P -n &amp;quot;[^\x00-\x7F]&amp;quot; file.xml&lt;br /&gt;
&lt;br /&gt;
 echo &amp;#039;소녀시대&amp;#039; | grep -P &amp;quot;[\x80-\xFF]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 grep -axv &amp;#039;.*&amp;#039; file.txt  # doesn&amp;#039;t seem to work on anything&lt;br /&gt;
&lt;br /&gt;
Sample: https://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html&lt;br /&gt;
&lt;br /&gt;
ref: https://stackoverflow.com/questions/3001177/how-do-i-grep-for-all-non-ascii-characters&lt;br /&gt;
&lt;br /&gt;
== Detect Corrupted Unicode Characters ==&lt;br /&gt;
&lt;br /&gt;
 awk &amp;#039;/[^\x00-\x7F]/{ print NR &amp;quot;:&amp;quot;, $0 }&amp;#039; file.txt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ awk &amp;#039;/[^\x00-\x7F]/{ print NR &amp;quot;:&amp;quot;, $0 }&amp;#039; file&lt;br /&gt;
1: Interruptor EC nÃ£o estÃ¡ em DESLOCAR&lt;br /&gt;
4: è¾…åŠ©é©¾é©¶å®¤é—¨å…³é—­&lt;br /&gt;
5: Porte cab. aux. fermÃ©e&lt;br /&gt;
7: Ð”Ð²ÐµÑ€ÑŒ Ð°Ð¿Ð¿Ð°Ñ€Ð°Ñ‚Ð½Ð¾Ð¹ ÐºÐ°Ð¼ÐµÑ€Ñ‹ Ð·Ð°ÐºÑ€Ñ‹Ñ‚Ð°&lt;br /&gt;
13: é«˜åŽ‹ä¿æŠ¤æ‰‹æŸ„å‘ä¸‹&lt;br /&gt;
14: BarriÃ¨re descendue&lt;br /&gt;
16: ÐžÐ³Ñ€Ð°Ð½Ð¸Ñ‡. ÐŸÐ»Ð°Ð½ÐºÐ° Ð’Ð’Ðš Ð¾Ð¿ÑƒÑ‰.&lt;br /&gt;
19: Barra de separaÃ§Ã£o descida&lt;br /&gt;
22: DPæœªå¯åŠ¨&lt;br /&gt;
23: Puiss. rÃ©p. non activÃ©e&lt;br /&gt;
25: !!! Ð’Ð½ÐµÑˆÐ½ÑÑ Ð¼Ð¾Ñ‰Ð½Ð¾ÑÑ‚ÑŒ Ð½Ðµ Ð²ÐºÐ»ÑŽÑ‡ÐµÐ½Ð°&lt;br /&gt;
26: PotÃªncia Dist NÃ£o Ativada&lt;br /&gt;
28: PotÃªncia dist nÃ£o activada&lt;br /&gt;
31: æœºè½¦æœªç§»åŠ¨&lt;br /&gt;
33: Motor no se estÃ¡ moviendo&lt;br /&gt;
34: Ð›Ð¾ÐºÐ¾Ð¼Ð¾Ñ‚Ð¸Ð² Ð½ÐµÐ¿Ð¾Ð´Ð²Ð¸Ð¶ÐµÐ½&lt;br /&gt;
35: Auto NÃ£o se Movendo&lt;br /&gt;
37: A nÃ£o se move&lt;br /&gt;
40: æœºè½¦çŠ¶å†µå…è®¸è‡ªåŠ¨åœæœº&lt;br /&gt;
41: Conditions auto\npermettent arrÃªt auto&lt;br /&gt;
43: Ð£ÑÑ‚Ð°Ð½Ð¾Ð²ÐºÐ¸ Ð»Ð¾ÐºÐ¾Ð¼Ð¾Ñ‚Ð¸Ð²Ð°\nÐŸÑ€ÐµÐ´ÑƒÑÐ¼Ð°Ñ‚Ñ€Ð¸Ð²Ð°ÑŽÑ‚ Ð     °Ð²Ñ‚Ð¾Ð¼Ð°Ñ‚Ð¸Ñ‡ÐµÑÐºÑƒÑŽ Ð¾ÑÑ‚Ð°Ð½Ð¾Ð²ÐºÑƒ&lt;br /&gt;
44: CondiÃ§Ãµes da moto\nPermitem Auto Parada&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ref: https://stackoverflow.com/questions/30738924/detecting-corrupt-characters-in-utf-8-encoded-text-file&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
Assuming you have your locale set to UTF-8 (see locale output), this works well to recognize invalid UTF-8 sequences:&lt;br /&gt;
&lt;br /&gt;
 grep -axv &amp;#039;.*&amp;#039; file.txt&lt;br /&gt;
&lt;br /&gt;
Ref: https://stackoverflow.com/questions/29465612/how-to-detect-invalid-utf8-unicode-binary-in-a-text-file&lt;br /&gt;
&lt;br /&gt;
== keywords ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux]]&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>