Skip to main content
Markdown list formatting
Source Link
muru
  • 78.3k
  • 16
  • 214
  • 320

You are assuming the wrong association of operators, and possibly their meaning. Numbering your tests cases:

(1) $0 ~/[Ss]ystem/ checks if "$0 matches /RE/". The || /puls/ condition is not even tested: it is "short-circuited" because the overall condition is already known to be true.

(2) The && checks if both conditions are true, and matches only one line.

(3) The combined RE (two alternative cases with |) matches two lines.

(4) This matches both the stored lines that contain System.

(5) This matches nothing. It tests a stored line from the array, but the '/puls/' tests the value in $0 after you have run off the end of the file -- it does not refer to k1[i]. $0 would still contain the last line of the file, and I conjecture that the complete input file has no such line at the end. The && requires both conditions to be true, so no line matches.

(6) Is a duplicate of (5).

(7) is a duplicate of (2).

  1. $0 ~/[Ss]ystem/ checks if "$0 matches /RE/". The || /puls/ condition is not even tested: it is "short-circuited" because the overall condition is already known to be true.

  2. The && checks if both conditions are true, and matches only one line.

  3. The combined RE (two alternative cases with |) matches two lines.

  4. This matches both the stored lines that contain System.

  5. This matches nothing. It tests a stored line from the array, but the '/puls/' tests the value in $0 after you have run off the end of the file -- it does not refer to k1[i]. $0 would still contain the last line of the file, and I conjecture that the complete input file has no such line at the end. The && requires both conditions to be true, so no line matches.

  6. Is a duplicate of (5).

  7. is a duplicate of (2).

You are assuming the wrong association of operators, and possibly their meaning. Numbering your tests cases:

(1) $0 ~/[Ss]ystem/ checks if "$0 matches /RE/". The || /puls/ condition is not even tested: it is "short-circuited" because the overall condition is already known to be true.

(2) The && checks if both conditions are true, and matches only one line.

(3) The combined RE (two alternative cases with |) matches two lines.

(4) This matches both the stored lines that contain System.

(5) This matches nothing. It tests a stored line from the array, but the '/puls/' tests the value in $0 after you have run off the end of the file -- it does not refer to k1[i]. $0 would still contain the last line of the file, and I conjecture that the complete input file has no such line at the end. The && requires both conditions to be true, so no line matches.

(6) Is a duplicate of (5).

(7) is a duplicate of (2).

You are assuming the wrong association of operators, and possibly their meaning. Numbering your tests cases:

  1. $0 ~/[Ss]ystem/ checks if "$0 matches /RE/". The || /puls/ condition is not even tested: it is "short-circuited" because the overall condition is already known to be true.

  2. The && checks if both conditions are true, and matches only one line.

  3. The combined RE (two alternative cases with |) matches two lines.

  4. This matches both the stored lines that contain System.

  5. This matches nothing. It tests a stored line from the array, but the '/puls/' tests the value in $0 after you have run off the end of the file -- it does not refer to k1[i]. $0 would still contain the last line of the file, and I conjecture that the complete input file has no such line at the end. The && requires both conditions to be true, so no line matches.

  6. Is a duplicate of (5).

  7. is a duplicate of (2).

Source Link
Paul_Pedant
  • 9.4k
  • 3
  • 24
  • 27

You are assuming the wrong association of operators, and possibly their meaning. Numbering your tests cases:

(1) $0 ~/[Ss]ystem/ checks if "$0 matches /RE/". The || /puls/ condition is not even tested: it is "short-circuited" because the overall condition is already known to be true.

(2) The && checks if both conditions are true, and matches only one line.

(3) The combined RE (two alternative cases with |) matches two lines.

(4) This matches both the stored lines that contain System.

(5) This matches nothing. It tests a stored line from the array, but the '/puls/' tests the value in $0 after you have run off the end of the file -- it does not refer to k1[i]. $0 would still contain the last line of the file, and I conjecture that the complete input file has no such line at the end. The && requires both conditions to be true, so no line matches.

(6) Is a duplicate of (5).

(7) is a duplicate of (2).