A NOTE has been added to this issue. ====================================================================== https://austingroupbugs.net/view.php?id=1464 ====================================================================== Reported By: mohd_akram Assigned To: ====================================================================== Project: 1003.1(2016/18)/Issue7+TC2 Issue ID: 1464 Category: Shell and Utilities Type: Enhancement Request Severity: Editorial Priority: normal Status: New Name: Mohamed Akram Organization: User Reference: Section: grep Page Number: 2842-2843 Line Number: 93588,93590,93592,93642 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2021-04-05 13:20 UTC Last Modified: 2021-04-05 17:08 UTC ====================================================================== Summary: grep(1): add -o option ======================================================================
---------------------------------------------------------------------- (0005302) stephane (reporter) - 2021-04-05 17:08 https://austingroupbugs.net/view.php?id=1464#c5302 ---------------------------------------------------------------------- Also note that with the GNU implementations (where the option comes from), only the non-empty matches are output (one per line). So you can be in a situation where nothing is output, but grep returns success as some lines matched. With the ast-open implementation (which is the grep builtin of ksh93 when built as part of ast-open), empty matches are output, but then you enter an infinite loop as the same match is found again and again. Try: <pre> echo foo | grep -o '^' </pre> for instance. In that implementation, <pre> $ echo foo | grep -o '^.' f o o </pre> As after the first match, "^." is matched against what follows on the line, so "oo" Some sed implementations have the same kind of issue with s/^./x/g or s/\<./x/g Issue History Date Modified Username Field Change ====================================================================== 2021-04-05 13:20 mohd_akram New Issue 2021-04-05 13:20 mohd_akram Name => Mohamed Akram 2021-04-05 13:20 mohd_akram Section => grep 2021-04-05 13:20 mohd_akram Page Number => 2842-2843 2021-04-05 13:20 mohd_akram Line Number => 93588,93590,93592,93642 2021-04-05 15:14 kre Note Added: 0005301 2021-04-05 17:08 stephane Note Added: 0005302 ======================================================================