I am running on Solaris 11, hence grep -o does not work.
What you provided me works but I'm looking for a command that works the same as 'grep -o' which works on Solaris.
Basically I have a log file and each line contains a timestamp. Therefore when performing uniq command, each line which contains that particular grep, is displayed separately.
To give you a better idea:
These are lines from the log file:
1 Sep 14 11:00:01 ccsWalletExpiry: [ID 848595 user.crit] ccsWalletExpiry(28635) CRITICAL: ABORTING: Cannot connect to O racle as '/'
1 Sep 14 11:00:06 ccsPeriodicCharge: [ID 848595 user.crit] ccsPeriodicCharge(28632) CRITICAL: Error: failed to initiali se database connection, cannot continue.
1 Sep 14 11:10:00 ccsWalletExpiry: [ID 848595 user.crit] ccsWalletExpiry(12949) CRITICAL: ABORTING: Cannot connect to O racle as '/'
I need to grep specifically for CRITICAL only and the output should be the string I'm trying to grep and the number of occurrences this string was matched
$ ./s1
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: SunOS, 5.11, i86pc
Distribution : Solaris 11.3 X86
bash GNU bash 4.1.17
ggrep (GNU grep) 2.14
-----
Input data file data1:
1 Sep 14 11:00:01 ccsWalletExpiry: [ID 848595 user.crit] ccsWalletExpiry(28635) CRITICAL: ABORTING: Cannot connect to O racle as '/'
1 Sep 14 11:00:06 ccsPeriodicCharge: [ID 848595 user.crit] ccsPeriodicCharge(28632) CRITICAL: Error: failed to initiali se database connection, cannot continue.
1 Sep 14 11:10:00 ccsWalletExpiry: [ID 848595 user.crit] ccsWalletExpiry(12949) CRITICAL: ABORTING: Cannot connect to O racle as '/'
-----
Expected output:
CRITICAL 3
-----
Results:
CRITICAL 3
-----
Verify results if possible:
-----
Comparison of 1 created lines with 1 lines of desired results:
Succeeded -- files (computed) f1 and (standard) expected-output1 have same content.
-----
Some details on /usr/bin/ggrep:
GREP(1) General Commands Manual GREP(1)
NAME
grep, egrep, fgrep - print lines matching a pattern