To search multiple strings or words using the grep command
1. Grep OR Using \|
Copyright (c) 2012, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/11.2.0.3.IREBSCNV
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/11.2.0.3.IREBSCNV/oraInst.loc
OPatch version : 11.2.0.3.0
OUI version : 11.2.0.3.0
Log file location : /u01/app/oracle/product/11.2.0.3.IREBSCNV/cfgtoollogs/opatch/opatch2013-03-18_09-50-20AM_1.log
Lsinventory Output file location : /u01/app/oracle/product/11.2.0.3.IREBSCNV/cfgtoollogs/opatch/lsinv/lsinventory2013-03-18_09-50-20AM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (1):
Oracle Database 11g 11.2.0.3.0
There are 1 products installed in this Oracle Home.
Interim patches (7) :
Patch 15876003 : applied on Sun Mar 03 11:53:57 GMT 2013
Unique Patch ID: 15750731
Patch description: "QUARTERLY CRS PATCH FOR EXADATA (JAN 2013 - 11.2.0.3.14) : (15876003)"
Created on 11 Jan 2013, 22:52:11 hrs PST8PDT
Bugs fixed:
15876003, 14275572, 13919095, 13696251, 13348650, 14407395, 12659561
13039908, 14277586, 13987807, 14625969, 13938166, 13825231, 13036424
12794268, 13011520, 13569812, 12758736, 13000491, 13498267, 13077654
13001901, 13550689, 13430715, 13806545, 13634583, 11675721, 14082976
14271305, 12771830, 12538907, 13947200, 12996428, 14102704, 13066371
13483672, 12594616, 13879428, 13540563, 12897651, 12897902, 13241779
12896850, 12726222, 12829429, 12728585, 13079948, 12876314, 13090686
12925041, 12995950, 13251796, 12650672, 12398492, 12848480, 13582411
13652088, 12990582, 13857364, 12975811, 12917897, 13653178, 13082238
12947871, 13037709, 13371153, 12878750, 10114953, 11772838, 13058611
13001955, 14001941, 11836951, 12965049, 13440962, 12765467, 13727853
13425727, 12885323, 13965075, 13339443, 12784559, 14242977, 13332363
13074261, 12971251, 13811209, 12709476, 14168708, 14096821, 13993634
13460353, 13523527, 12857064, 13719731, 13396284, 12899169, 13111013
12558569, 13323698, 12867511, 12639013, 10260842, 12959140, 13085732
12829917, 10317921, 13843080, 12934171, 12849377, 12349553, 13924431
13869978, 12680491, 12914824, 13789135, 12730342, 13334158, 12950823
10418841, 12832204, 13355963, 13531373, 13776758, 12720728, 13620816
13002015, 13023609, 13024624, 12791719
Patch 15835102 : applied on Sun Mar 03 11:47:48 GMT 2013
Unique Patch ID: 15750731
Patch description: "QUARTERLY DATABASE PATCH FOR EXADATA (JAN 2013 - 11.2.0.3.14) : (15835102)"
Created on 26 Dec 2012, 04:43:45 hrs PST8PDT
Bugs fixed:
14653598, 13332439, 13498646, 14198511, 14043417, 12625563, 13602883
12904429, 12831782, 14841409, 12793917, 14624146, 12791981, 12646784
12830174, 12857027, 13554409, 13717748, 13879553, 12585543, 12425262
12794305, 13629469, 14342378, 13942462, 12594032, 14507915, 13863326
12656535, 12938841, 14362875, 13440068, 13652437, 15862020, 13912192
14127231, 13550185, 13720544, 14465787, 13657460, 14226599, 14516040
13599864, 14063280, 12861463, 12913987, 10214323, 14251170, 12912297
13040943, 13457582, 13776598, 13784384, 7276499, 13515918, 13580513
14263073, 13732226, 13430938, 12953092, 13089313, 14207163, 13080778
13871495, 15853081, 13903046, 11063191, 11896575, 14334353, 12979199
14480674, 13484963, 14506367, 12984935, 12939232, 12879027, 13989185
14292825, 10263668, 14098509, 13705338, 14023636, 13467683, 11837095
13026410, 14589750, 13388104, 14548763, 13879579, 13344323, 10287724
13054713, 13399435, 14062797, 13976144, 13700577, 14113740, 12391034
13103913, 12328803, 14258925, 13906496, 14222403, 13923374, 14633213
13718279, 14205448, 14521920, 13355095, 13098318, 12771704, 12889054
13814905, 13719081, 12945290, 13421009, 13409719, 13945708, 9703627
11929808, 12905058, 11708510, 13743987, 13837105, 13986244, 13256841
14034244, 13742437, 14527701, 12621588, 12837280, 12960279, 12971775
13727644, 13328193, 13354082, 14005749, 14052474, 13645917, 14153033
12764658, 15862016, 12833442, 14114792, 14013094, 13657605, 13901039
13011409, 13632809, 13528551, 14698700, 8547978, 13742435, 13466801
14088346, 13429678, 12556843, 14132953, 13070939, 15951085, 13979519
12929644, 14741727, 13362079, 14301592, 14062792, 13909322, 12918738
13099577, 13917937, 13566938, 12757532, 13775960, 10297948, 13242070
13742436, 13871547, 13913630, 12358083, 12913474, 13812031, 14654284
13575265, 14301697, 12780983, 12898733, 13725395, 9163477, 10136532
12401111, 13477790, 14546673, 12971388, 9906567, 12325317, 14098382
12582664, 14153464, 13882317, 9873405, 12974860, 12693573, 12766987
13901133, 14348839, 13714302, 13358781, 12658411, 12618817, 9095696
14117976, 13397256, 14671833, 14143451, 13426605, 11840910, 13448247
13257247, 14174174, 13476583, 13593999, 12966665, 14546575, 14062793
10625145, 13816397, 14651753, 13527323, 12940620, 14317360, 12718090
13035360, 13579992, 13343438, 12780098, 13001379, 10133521, 12848798
14506175, 13936424, 13544396, 13742434, 14587310, 13572659, 12637294
12900077, 12873183, 13395403, 12950694, 12894807, 14029050, 13927155
12350994, 14262913, 12899768, 14480676, 13559697, 13722707, 13326736
13804294, 14175146, 14182835, 13483354, 10182005, 9876287, 12794025
10418524, 9847699, 14561651, 12849688, 13632717, 12890501, 11071989
15862023, 12772404, 12834027, 11855445, 12922105, 14499293, 13687870
12586845, 13370330, 13902316, 12723359, 12959852, 13649031, 13036331
12944766, 13553883, 13493847, 13839641, 13464002, 13117043, 13929853
12693626, 10350832, 13851078, 12847466, 13023541, 12974145, 13742433
13719292, 13612575, 13642207, 10305573, 13811172, 14062795, 13340960
13718476, 12678920, 13063120, 12353494, 12731940, 13352237, 13961338
9659614, 13506110, 12925089, 13524237, 13495307, 15862018, 14467061
12876939, 12780993, 13715680, 14071518, 13419747, 12325243, 13524698
12595561, 12917230, 13769887, 14668670, 13384397, 13253549, 14207317
12998795, 12953743, 14473913, 10248538, 15862017, 13329145, 13685544
13790109, 12748240, 13032258, 12620823, 13711695, 13366202, 14482905
13624984, 12709059, 13038684, 12345082, 14008285, 13584130, 12880299
14042380, 13499128, 13364795, 13787482, 13860201, 12617123, 13422949
12924835, 11877623, 14294123, 14007968, 12564614, 13340388, 13998753
12535346, 11841048, 13629056, 13259364, 12923168, 14607573, 12748795
13737746, 13918644, 13564720, 13384182, 14390252, 14038787, 12662040
9761357, 13645875, 14062796, 12960925, 13470240, 14050233, 14052871
13773133, 12734325, 3522216, 13516727, 14409183, 13916709, 12842402
14314239, 14144283, 14218148, 13853916, 13902963, 14275605, 14016187
12685263, 13912642, 14287564, 12698747, 14215134, 10332676, 12983611
13022416, 14119388, 13000553, 15862024, 12536287, 12778873, 15862019
13502183, 12866794, 13471777, 13533487, 13742438, 12628286, 12717125
12768840, 12797420, 11715084, 13041324, 12387467, 12714023, 13350245
12612118, 12900964, 13074706, 10387201, 13767790, 14546638, 13958038
12591252, 13440516, 13887875, 12627504, 12797765, 13111630, 14292987
13457537, 13699124, 13981051, 13492735, 13772618, 13503598, 12829021
13968438, 14664355, 13588248, 12749597, 8316255, 13345786, 12964067
13419660, 14097127, 13146719, 12583611, 12591399, 14309390, 13035804
9706792, 13898864, 14402514, 15862021, 13146182, 13503766, 13385346
12312133, 6445864, 13716797, 14744263, 12920172, 13807411, 13880971
14469008, 14291951, 14063281, 14125317, 12865902, 14508968, 13801740
12899094, 12960455, 13914613, 9782075, 14299365, 14366237, 14110275
11717119, 13040331, 13997862, 13420224, 11868640, 13250244, 13573203
13505390, 14356507, 12326708, 14014434, 13911821, 12978794, 12596444
12675009, 12919564, 12614359, 14293031, 9858539, 14557588, 14237793
13454210, 13786778, 14062794, 12764337, 14478870, 12539239, 13448206
14040433, 12748538, 14076523, 14128555, 13358531, 14176879, 14480675
12641849, 13059165, 14613900, 14692460, 14578331, 14393900, 14512189
13534412, 13910420, 13742464, 13377816, 13397104, 13079417, 13004894
13696023, 12672969, 13642044, 13478060, 12655301, 12976376, 14280879
14041920, 14112837, 13524899, 13786142, 12845115, 15862022, 14263036
12910565, 13780816, 13696216, 13548053, 14727310, 13724193, 14035825
12950644, 12588744, 9725536, 13338048, 14138130
Patch 4247037 : applied on Thu May 10 21:45:42 IST 2012
Unique Patch ID: 14211388
Created on 17 SEP 2009, 09:52:00 hrs US/Pacific
Bugs fixed:
4247037
Patch 13366268 : applied on Thu May 10 21:44:31 IST 2012
Unique Patch ID: 14394336
Created on 21 Dec 2011, 08:14:06 hrs PST8PDT
Bugs fixed:
13366268
Patch 13258936 : applied on Thu May 10 21:43:30 IST 2012
Unique Patch ID: 14465000
Created on 5 Dec 2011, 02:41:32 hrs PST8PDT
Bugs fixed:
13258936
Patch 12985184 : applied on Thu May 10 21:38:43 IST 2012
Unique Patch ID: 14296756
Created on 30 Nov 2011, 15:18:06 hrs PST8PDT
Bugs fixed:
12985184
Patch 12960302 : applied on Thu May 10 21:36:56 IST 2012
Unique Patch ID: 14254250
Created on 10 Nov 2011, 02:40:18 hrs PST8PDT
Bugs fixed:
12960302
Rac system comprising of multiple nodes
Local node = igrexanwh001d02
Remote node = igrexanwh001d01
Remote node = igrexanwh001d03
Remote node = igrexanwh001d04
--------------------------------------------------------------------------------
OPatch succeeded.
[oracle@igrexanwh001d02 OPatch]$ /u01/app/grid/11.2.0.3/OPatch/opatch lsinventory | grep '4247037\|12942119\|12960302\|12985184\|13258936\|13366268\|14313519'
Patch 4247037 : applied on Thu May 10 21:45:42 IST 2012
4247037
Patch 13366268 : applied on Thu May 10 21:44:31 IST 2012
13366268
Patch 13258936 : applied on Thu May 10 21:43:30 IST 2012
13258936
Patch 12985184 : applied on Thu May 10 21:38:43 IST 2012
12985184
Patch 12960302 : applied on Thu May 10 21:36:56 IST 2012
12960302
you could also use [oracle@igrexanwh001d02 OPatch]$ /u01/app/grid/11.2.0.3/OPatch/opatch lsinventory | grep -E '4247037|12942119|12960302|12985184|13258936|13366268|14313519' which will give you the same result.
egrep 'pattern1|pattern2' filename
4. Grep AND Opertion
$ grep -E ‘pattern1.*pattern2′ (with order)
Some more grep options,
grep -v you can list down all files which doesn't contains a word i.e. excluding files which matches a pattern
cat textfile.txt | grep -v “Hello”
World
grep -c will print count of matching pattern in a file etc
cat textfile.txt | grep -c “Hello”
3
grep -i for case insensitive
cat textfile.txt | grep -i “Hello”
grep -i “Hello” textfile.txt
More options, I'l mention as I discover in future... :)
1. Grep OR Using \|
[oracle@igrexanwh001d02 OPatch]$ /u01/app/grid/11.2.0.3/OPatch/opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.0Copyright (c) 2012, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/11.2.0.3.IREBSCNV
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/11.2.0.3.IREBSCNV/oraInst.loc
OPatch version : 11.2.0.3.0
OUI version : 11.2.0.3.0
Log file location : /u01/app/oracle/product/11.2.0.3.IREBSCNV/cfgtoollogs/opatch/opatch2013-03-18_09-50-20AM_1.log
Lsinventory Output file location : /u01/app/oracle/product/11.2.0.3.IREBSCNV/cfgtoollogs/opatch/lsinv/lsinventory2013-03-18_09-50-20AM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (1):
Oracle Database 11g 11.2.0.3.0
There are 1 products installed in this Oracle Home.
Interim patches (7) :
Patch 15876003 : applied on Sun Mar 03 11:53:57 GMT 2013
Unique Patch ID: 15750731
Patch description: "QUARTERLY CRS PATCH FOR EXADATA (JAN 2013 - 11.2.0.3.14) : (15876003)"
Created on 11 Jan 2013, 22:52:11 hrs PST8PDT
Bugs fixed:
15876003, 14275572, 13919095, 13696251, 13348650, 14407395, 12659561
13039908, 14277586, 13987807, 14625969, 13938166, 13825231, 13036424
12794268, 13011520, 13569812, 12758736, 13000491, 13498267, 13077654
13001901, 13550689, 13430715, 13806545, 13634583, 11675721, 14082976
14271305, 12771830, 12538907, 13947200, 12996428, 14102704, 13066371
13483672, 12594616, 13879428, 13540563, 12897651, 12897902, 13241779
12896850, 12726222, 12829429, 12728585, 13079948, 12876314, 13090686
12925041, 12995950, 13251796, 12650672, 12398492, 12848480, 13582411
13652088, 12990582, 13857364, 12975811, 12917897, 13653178, 13082238
12947871, 13037709, 13371153, 12878750, 10114953, 11772838, 13058611
13001955, 14001941, 11836951, 12965049, 13440962, 12765467, 13727853
13425727, 12885323, 13965075, 13339443, 12784559, 14242977, 13332363
13074261, 12971251, 13811209, 12709476, 14168708, 14096821, 13993634
13460353, 13523527, 12857064, 13719731, 13396284, 12899169, 13111013
12558569, 13323698, 12867511, 12639013, 10260842, 12959140, 13085732
12829917, 10317921, 13843080, 12934171, 12849377, 12349553, 13924431
13869978, 12680491, 12914824, 13789135, 12730342, 13334158, 12950823
10418841, 12832204, 13355963, 13531373, 13776758, 12720728, 13620816
13002015, 13023609, 13024624, 12791719
Patch 15835102 : applied on Sun Mar 03 11:47:48 GMT 2013
Unique Patch ID: 15750731
Patch description: "QUARTERLY DATABASE PATCH FOR EXADATA (JAN 2013 - 11.2.0.3.14) : (15835102)"
Created on 26 Dec 2012, 04:43:45 hrs PST8PDT
Bugs fixed:
14653598, 13332439, 13498646, 14198511, 14043417, 12625563, 13602883
12904429, 12831782, 14841409, 12793917, 14624146, 12791981, 12646784
12830174, 12857027, 13554409, 13717748, 13879553, 12585543, 12425262
12794305, 13629469, 14342378, 13942462, 12594032, 14507915, 13863326
12656535, 12938841, 14362875, 13440068, 13652437, 15862020, 13912192
14127231, 13550185, 13720544, 14465787, 13657460, 14226599, 14516040
13599864, 14063280, 12861463, 12913987, 10214323, 14251170, 12912297
13040943, 13457582, 13776598, 13784384, 7276499, 13515918, 13580513
14263073, 13732226, 13430938, 12953092, 13089313, 14207163, 13080778
13871495, 15853081, 13903046, 11063191, 11896575, 14334353, 12979199
14480674, 13484963, 14506367, 12984935, 12939232, 12879027, 13989185
14292825, 10263668, 14098509, 13705338, 14023636, 13467683, 11837095
13026410, 14589750, 13388104, 14548763, 13879579, 13344323, 10287724
13054713, 13399435, 14062797, 13976144, 13700577, 14113740, 12391034
13103913, 12328803, 14258925, 13906496, 14222403, 13923374, 14633213
13718279, 14205448, 14521920, 13355095, 13098318, 12771704, 12889054
13814905, 13719081, 12945290, 13421009, 13409719, 13945708, 9703627
11929808, 12905058, 11708510, 13743987, 13837105, 13986244, 13256841
14034244, 13742437, 14527701, 12621588, 12837280, 12960279, 12971775
13727644, 13328193, 13354082, 14005749, 14052474, 13645917, 14153033
12764658, 15862016, 12833442, 14114792, 14013094, 13657605, 13901039
13011409, 13632809, 13528551, 14698700, 8547978, 13742435, 13466801
14088346, 13429678, 12556843, 14132953, 13070939, 15951085, 13979519
12929644, 14741727, 13362079, 14301592, 14062792, 13909322, 12918738
13099577, 13917937, 13566938, 12757532, 13775960, 10297948, 13242070
13742436, 13871547, 13913630, 12358083, 12913474, 13812031, 14654284
13575265, 14301697, 12780983, 12898733, 13725395, 9163477, 10136532
12401111, 13477790, 14546673, 12971388, 9906567, 12325317, 14098382
12582664, 14153464, 13882317, 9873405, 12974860, 12693573, 12766987
13901133, 14348839, 13714302, 13358781, 12658411, 12618817, 9095696
14117976, 13397256, 14671833, 14143451, 13426605, 11840910, 13448247
13257247, 14174174, 13476583, 13593999, 12966665, 14546575, 14062793
10625145, 13816397, 14651753, 13527323, 12940620, 14317360, 12718090
13035360, 13579992, 13343438, 12780098, 13001379, 10133521, 12848798
14506175, 13936424, 13544396, 13742434, 14587310, 13572659, 12637294
12900077, 12873183, 13395403, 12950694, 12894807, 14029050, 13927155
12350994, 14262913, 12899768, 14480676, 13559697, 13722707, 13326736
13804294, 14175146, 14182835, 13483354, 10182005, 9876287, 12794025
10418524, 9847699, 14561651, 12849688, 13632717, 12890501, 11071989
15862023, 12772404, 12834027, 11855445, 12922105, 14499293, 13687870
12586845, 13370330, 13902316, 12723359, 12959852, 13649031, 13036331
12944766, 13553883, 13493847, 13839641, 13464002, 13117043, 13929853
12693626, 10350832, 13851078, 12847466, 13023541, 12974145, 13742433
13719292, 13612575, 13642207, 10305573, 13811172, 14062795, 13340960
13718476, 12678920, 13063120, 12353494, 12731940, 13352237, 13961338
9659614, 13506110, 12925089, 13524237, 13495307, 15862018, 14467061
12876939, 12780993, 13715680, 14071518, 13419747, 12325243, 13524698
12595561, 12917230, 13769887, 14668670, 13384397, 13253549, 14207317
12998795, 12953743, 14473913, 10248538, 15862017, 13329145, 13685544
13790109, 12748240, 13032258, 12620823, 13711695, 13366202, 14482905
13624984, 12709059, 13038684, 12345082, 14008285, 13584130, 12880299
14042380, 13499128, 13364795, 13787482, 13860201, 12617123, 13422949
12924835, 11877623, 14294123, 14007968, 12564614, 13340388, 13998753
12535346, 11841048, 13629056, 13259364, 12923168, 14607573, 12748795
13737746, 13918644, 13564720, 13384182, 14390252, 14038787, 12662040
9761357, 13645875, 14062796, 12960925, 13470240, 14050233, 14052871
13773133, 12734325, 3522216, 13516727, 14409183, 13916709, 12842402
14314239, 14144283, 14218148, 13853916, 13902963, 14275605, 14016187
12685263, 13912642, 14287564, 12698747, 14215134, 10332676, 12983611
13022416, 14119388, 13000553, 15862024, 12536287, 12778873, 15862019
13502183, 12866794, 13471777, 13533487, 13742438, 12628286, 12717125
12768840, 12797420, 11715084, 13041324, 12387467, 12714023, 13350245
12612118, 12900964, 13074706, 10387201, 13767790, 14546638, 13958038
12591252, 13440516, 13887875, 12627504, 12797765, 13111630, 14292987
13457537, 13699124, 13981051, 13492735, 13772618, 13503598, 12829021
13968438, 14664355, 13588248, 12749597, 8316255, 13345786, 12964067
13419660, 14097127, 13146719, 12583611, 12591399, 14309390, 13035804
9706792, 13898864, 14402514, 15862021, 13146182, 13503766, 13385346
12312133, 6445864, 13716797, 14744263, 12920172, 13807411, 13880971
14469008, 14291951, 14063281, 14125317, 12865902, 14508968, 13801740
12899094, 12960455, 13914613, 9782075, 14299365, 14366237, 14110275
11717119, 13040331, 13997862, 13420224, 11868640, 13250244, 13573203
13505390, 14356507, 12326708, 14014434, 13911821, 12978794, 12596444
12675009, 12919564, 12614359, 14293031, 9858539, 14557588, 14237793
13454210, 13786778, 14062794, 12764337, 14478870, 12539239, 13448206
14040433, 12748538, 14076523, 14128555, 13358531, 14176879, 14480675
12641849, 13059165, 14613900, 14692460, 14578331, 14393900, 14512189
13534412, 13910420, 13742464, 13377816, 13397104, 13079417, 13004894
13696023, 12672969, 13642044, 13478060, 12655301, 12976376, 14280879
14041920, 14112837, 13524899, 13786142, 12845115, 15862022, 14263036
12910565, 13780816, 13696216, 13548053, 14727310, 13724193, 14035825
12950644, 12588744, 9725536, 13338048, 14138130
Patch 4247037 : applied on Thu May 10 21:45:42 IST 2012
Unique Patch ID: 14211388
Created on 17 SEP 2009, 09:52:00 hrs US/Pacific
Bugs fixed:
4247037
Patch 13366268 : applied on Thu May 10 21:44:31 IST 2012
Unique Patch ID: 14394336
Created on 21 Dec 2011, 08:14:06 hrs PST8PDT
Bugs fixed:
13366268
Patch 13258936 : applied on Thu May 10 21:43:30 IST 2012
Unique Patch ID: 14465000
Created on 5 Dec 2011, 02:41:32 hrs PST8PDT
Bugs fixed:
13258936
Patch 12985184 : applied on Thu May 10 21:38:43 IST 2012
Unique Patch ID: 14296756
Created on 30 Nov 2011, 15:18:06 hrs PST8PDT
Bugs fixed:
12985184
Patch 12960302 : applied on Thu May 10 21:36:56 IST 2012
Unique Patch ID: 14254250
Created on 10 Nov 2011, 02:40:18 hrs PST8PDT
Bugs fixed:
12960302
Rac system comprising of multiple nodes
Local node = igrexanwh001d02
Remote node = igrexanwh001d01
Remote node = igrexanwh001d03
Remote node = igrexanwh001d04
--------------------------------------------------------------------------------
OPatch succeeded.
[oracle@igrexanwh001d02 OPatch]$ /u01/app/grid/11.2.0.3/OPatch/opatch lsinventory | grep '4247037\|12942119\|12960302\|12985184\|13258936\|13366268\|14313519'
Patch 4247037 : applied on Thu May 10 21:45:42 IST 2012
4247037
Patch 13366268 : applied on Thu May 10 21:44:31 IST 2012
13366268
Patch 13258936 : applied on Thu May 10 21:43:30 IST 2012
13258936
Patch 12985184 : applied on Thu May 10 21:38:43 IST 2012
12985184
Patch 12960302 : applied on Thu May 10 21:36:56 IST 2012
12960302
From above output, we can conclude that Patch 12942119 & 14313519 is not applied.
2. Grep OR Using -E
3. Grep OR Using egrep
egrep is exactly same as ‘grep -E’. So, use egrep (without any option) and separate multiple patterns for the or condition.
4. Grep AND Opertion
$ grep -E ‘pattern1.*pattern2′ (with order)
$ grep -E 'pattern1.*pattern2|pattern2.*pattern1' filename (without order)
Some more grep options,
grep -v you can list down all files which doesn't contains a word i.e. excluding files which matches a pattern
cat textfile.txt | grep -v “Hello”
World
grep -c will print count of matching pattern in a file etc
cat textfile.txt | grep -c “Hello”
3
grep -i for case insensitive
cat textfile.txt | grep -i “Hello”
grep -i “Hello” textfile.txt
More options, I'l mention as I discover in future... :)
No comments:
Post a Comment