TMS6 Linux Search Commands |
grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Grep was originally developed for the Unix operating system, but is available today for all Unix-like systems. Its name comes from the ed command g/re/p (globally search aregular expression and print), which has the same effect: doing a global search with the regular expression and printing all matching lines.
Find Processes
[tms6@localhost trace]$ ps -ef|grep bay
tms6587010 Jun22 ?00:00:00 /tms6/bin/bay_pct
tms6613740040 Jun22 ?00:01:24 /toptech_prj/bin/bay_rcu b=05
tms6613940040 Jun22 ?00:01:18 /toptech_prj/bin/bay_rcu b=06
tms616202 150170 09:33 pts/100:00:00 grep bay
tms63025140040 00:11 ?00:00:10 /toptech_prj/bin/bay_rcu tlc_ver=4 b=01
tms63025540040 00:11 ?00:00:07 /toptech_prj/bin/bay_rcu tlc_ver=4 b=02
tms63026240040 00:11 ?00:00:07 /toptech_prj/bin/bay_rcu tlc_ver=4 b=03
tms63026940040 00:11 ?00:00:09 /toptech_prj/bin/bay_rcu tlc_ver=4 b=04
[tms6@localhost trace]$ ps aux|grep bay
tms658700.00.0100041396 ?SsJun220:00 /tms6/bin/bay_pct
tms6 61370.00.0124164056 ?SJun221:24 /toptech_prj/bin/bay_rcu b=05
tms661390.00.1129244456 ?SJun221:18 /toptech_prj/bin/bay_rcu b=06
tms6162420.00.01948556 pts/1S+09:330:00 grep bay
tms6302510.00.1126605052 ?S00:110:10 /toptech_prj/bin/bay_rcu tlc_ver=4 b=01
tms6302550.00.1126605084 ?S00:110:07 /toptech_prj/bin/bay_rcu tlc_ver=4 b=02
tms6302620.00.0126803824 ?S00:110:07 /toptech_prj/bin/bay_rcu tlc_ver=4 b=03
tms6302690.00.1127165068 ?S00:110:09 /toptech_prj/bin/bay_rcu tlc_ver=4 b=04
Find Process by name
[tms6@localhost trace]$ sin na|grep bay
BAY_PCT5870/tms6/bin/bay_pct
BAY0130251/toptech_prj/bin/bay_rcu tlc_ver=4 b=01
BAY0230255/toptech_prj/bin/bay_rcu tlc_ver=4 b=02
BAY0330262/toptech_prj/bin/bay_rcu tlc_ver=4 b=03
BAY0430269/toptech_prj/bin/bay_rcu tlc_ver=4 b=04
BAY056137/toptech_prj/bin/bay_rcu b=05
BAY066139/toptech_prj/bin/bay_rcu b=06
[tms6@localhost trace]$ sin na|grep RACK2
RACK24626/tms6/bin/lc n=RACK2 m=7734 tcpaddr=192.168.0.119 t=3000
DITTO-RACK2-0015287/tms6/bin/rcudittoserver n=RACK2 p=S d=001 +persist
Find a string of data in a file
Change directory to location of the file
[tms6@CNRCFL ~]$ cd /tms6/log/trace
Verify file data exists
[tms6@CNRCFL trace]$ ls -l
total 238956
-rw-r--r-- 1 tms6 toptech 133 Feb 15 13:07 folio.scott
-rw-r--r-- 1 tms6 toptech 36868 Feb 15 12:46 tmsfolio.scott
-rw-rw-r-- 1 tms6 toptech 12014509 Feb 5 23:59 tracelog.160205
-rw-rw-r-- 1 tms6 toptech 15812952 Feb 6 23:59 tracelog.160206
-rw-rw-r-- 1 tms6 toptech 11426038 Feb 7 23:59 tracelog.160207
-rw-rw-r-- 1 tms6 toptech 14190588 Feb 8 23:59 tracelog.160208
-rw-rw-r-- 1 tms6 toptech 14336793 Feb 9 23:59 tracelog.160209
-rw-rw-r-- 1 tms6 toptech 18381924 Feb 10 23:59 tracelog.160210
-rw-rw-r-- 1 tms6 toptech 17485296 Feb 11 23:59 tracelog.160211
-rw-rw-r-- 1 tms6 toptech 18407350 Feb 12 23:59 tracelog.160212
-rw-rw-r-- 1 tms6 toptech 17889011 Feb 13 23:59 tracelog.160213
-rw-rw-r-- 1 tms6 toptech 11768016 Feb 14 23:59 tracelog.160214
-rw-rw-r-- 1 tms6 toptech 16751814 Feb 15 23:59 tracelog.160215
-rw-rw-r-- 1 tms6 toptech 11152946 Feb 16 23:59 tracelog.160216
-rw-rw-r-- 1 tms6 toptech 16993352 Feb 17 23:59 tracelog.160217
-rw-rw-r-- 1 tms6 toptech 11587974 Feb 18 23:59 tracelog.160218
-rw-rw-r-- 1 tms6 toptech 13723287 Feb 19 23:59 tracelog.160219
-rw-rw-r-- 1 tms6 toptech 15077353 Feb 20 23:59 tracelog.160220
-rw-rw-r-- 1 tms6 toptech 7196929 Feb 21 15:04 tracelog.160221
Use grep to search for the string ALARM from the file tracelog.160221
[tms6@CNRCFL trace]$ grep ALARM tracelog.160221
02/21/16 00:00:18:556358 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 C5
02/21/16 00:00:18:560542 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 M6
02/21/16 00:00:18:562027 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 P5
02/21/16 00:00:18:563548 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: COMPONENT LEVEL ALARM INDICATED ! ***
02/21/16 00:00:18:564942 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: COMPONENT (0) METER ALARM ! ***
02/21/16 00:00:18:567154 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
-i parameter will ignore case
[tms6@CNRCFL trace]$ grep -i alarm tracelog.160221
02/21/16 00:00:18:556358 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 C5
02/21/16 00:00:18:560542 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 M6
02/21/16 00:00:18:562027 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 P5
02/21/16 00:00:18:563548 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: COMPONENT LEVEL ALARM INDICATED ! ***
02/21/16 00:00:18:564942 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: COMPONENT (0) METER ALARM ! ***
Use –e parameter to search for multiple strings with each string in quotes
[tms6@CNRCFL trace]$ grep -e "ALARM" -e "Driver" tracelog.160221
02/21/16 00:00:18:556358 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 C5
02/21/16 00:00:18:560542 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 M6
02/21/16 00:00:18:562027 CNRCFL:03950 unitmtl - [0104] Clearing RACKSTAT ALARM 0000002 M0104 P5
02/21/16 00:00:18:563548 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: COMPONENT LEVEL ALARM INDICATED ! ***
02/21/16 00:00:18:564942 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: COMPONENT (0) METER ALARM ! ***
02/21/16 00:00:18:567154 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 00:00:21:135249 CNRCFL:03934 unitmtl - [0101] Clearing RACKSTAT ALARM 0000002 M0101 C5
02/21/16 00:00:21:136885 CNRCFL:03934 unitmtl - [0101] Clearing RACKSTAT ALARM 0000002 M0101 M6
02/21/16 00:00:21:138480 CNRCFL:03934 unitmtl - [0101] Clearing RACKSTAT ALARM 0000002 M0101 P5
02/21/16 00:00:21:139994 CNRCFL:03934 unitmtl - [0101] PRESET: *** ALARM CONDITION: COMPONENT LEVEL ALARM INDICATED ! ***
02/21/16 00:00:21:141928 CNRCFL:03934 unitmtl - [0101] PRESET: *** ALARM CONDITION: COMPONENT (0) METER ALARM ! ***
02/21/16 00:00:21:144115 CNRCFL:03934 unitmtl - [0101] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 00:01:01:340962 CNRCFL:03950 unitmtl - [0104] Received CMD_DRAIN, shutdown pending. State:ALARM
02/21/16 00:01:01:341273 CNRCFL:03950 unitmtl - [0104] SHUTDOWN PENDING: CARD OUT. State:ALARM
02/21/16 00:01:02:180850 CNRCFL:03934 unitmtl - [0101] Received CMD_DRAIN, shutdown pending. State:ALARM
02/21/16 00:01:02:181404 CNRCFL:03934 unitmtl - [0101] SHUTDOWN PENDING: CARD OUT. State:ALARM
02/21/16 00:01:28:513434 CNRCFL:10791 bay_rcu - Driver Override [N]
02/21/16 00:01:28:514432 CNRCFL:10801 bay_rcu - Driver Override [N]
02/21/16 00:01:28:520675 CNRCFL:10791 bay_rcu - [BAY01] No DriverSafetyViolationConfig - Records found
02/21/16 00:01:28:520755 CNRCFL:10791 bay_rcu - [BAY01] No DriverSafetyViolationConfig - Records to Print
02/21/16 00:01:28:521552 CNRCFL:10801 bay_rcu - [BAY03] No DriverSafetyViolationConfig - Records found
02/21/16 00:01:28:521625 CNRCFL:10801 bay_rcu - [BAY03] No DriverSafetyViolationConfig - Records to Print
Use Multiple grep commands to refine searches
[tms6@CNRCFL trace]$ grep -e "ALARM" tracelog.160221|grep LOW
02/21/16 00:00:18:567154 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 00:00:21:144115 CNRCFL:03934 unitmtl - [0101] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 00:01:29:440149 CNRCFL:10792 unitmtl - [0101] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 00:01:29:525508 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 01:00:01:871587 CNRCFL:10792 unitmtl - [0101] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 01:00:01:872861 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 02:00:07:605702 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 02:00:11:344215 CNRCFL:10792 unitmtl - [0101] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 03:00:18:651575 CNRCFL:10792 unitmtl - [0101] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
[tms6@CNRCFL trace]$ grep -e "ALARM" tracelog.160221|grep LOW|grep 0104
02/21/16 00:00:18:567154 CNRCFL:03950 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 00:01:29:525508 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 01:00:01:872861 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 02:00:07:605702 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 03:00:18:652879 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 04:00:20:724692 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 05:00:13:888368 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 06:00:19:559852 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 07:00:22:635466 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 08:00:03:396291 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 09:00:13:155539 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***
02/21/16 10:00:13:024826 CNRCFL:10795 unitmtl - [0104] PRESET: *** ALARM CONDITION: METER (0) LEVEL LOW FLOW ALARM ! ***