Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

The confusion may be caused by the fact that the original author used the same variable name for the shell:

benchmark=30;gr...

as he/she did inside awk:

awk -vbenchmark=$benchmark

which may or may notmay or may not assign the value of the shell variable benchmark to the awk variable benchmark.

Once awk has this value (30 in this case), awk checks that the 6th column of your input file wk.txt is greater than this value:

$6 > benchmark

The test, using your example, is therefore the string comparison:

for > 30

which, while legal, doesn't really doesn't make much sense. Is the example input file a genuine example or just random test?

This evaluates to true, therefore awk prints the whole line to wc -l which counts the number of lines. As you only have one line in your input file, the count of lines where the 6th column is greater that 30 is 1.

This value is assigned to the shell variable b.

The confusion may be caused by the fact that the original author used the same variable name for the shell:

benchmark=30;gr...

as he/she did inside awk:

awk -vbenchmark=$benchmark

which may or may not assign the value of the shell variable benchmark to the awk variable benchmark.

Once awk has this value (30 in this case), awk checks that the 6th column of your input file wk.txt is greater than this value:

$6 > benchmark

The test, using your example, is therefore the string comparison:

for > 30

which, while legal, doesn't really doesn't make much sense. Is the example input file a genuine example or just random test?

This evaluates to true, therefore awk prints the whole line to wc -l which counts the number of lines. As you only have one line in your input file, the count of lines where the 6th column is greater that 30 is 1.

This value is assigned to the shell variable b.

The confusion may be caused by the fact that the original author used the same variable name for the shell:

benchmark=30;gr...

as he/she did inside awk:

awk -vbenchmark=$benchmark

which may or may not assign the value of the shell variable benchmark to the awk variable benchmark.

Once awk has this value (30 in this case), awk checks that the 6th column of your input file wk.txt is greater than this value:

$6 > benchmark

The test, using your example, is therefore the string comparison:

for > 30

which, while legal, doesn't really doesn't make much sense. Is the example input file a genuine example or just random test?

This evaluates to true, therefore awk prints the whole line to wc -l which counts the number of lines. As you only have one line in your input file, the count of lines where the 6th column is greater that 30 is 1.

This value is assigned to the shell variable b.

Added link to QA on quoting shell variables
Source Link
garethTheRed
  • 35k
  • 4
  • 101
  • 106

The confusion may be caused by the fact that the original author used the same variable name for the shell:

benchmark=30;gr...

as he/she did inside awk:

awk -vbenchmark=$benchmark

which assignsmay or may not assign the value of the shell variable benchmark to the awk variable benchmark.

Once awk has this value (30 in this case), awk checks that the 6th column of your input file wk.txt is greater than this value:

$6 > benchmark

The test, using your example, is therefore the string comparison:

for > 30

which, while legal, doesn't really doesn't make much sense. Is the example input file a genuine example or just random test?

This evaluates to true, therefore awk prints the whole line to wc -l which counts the number of lines. As you only have one line in your input file, the count of lines where the 6th column is greater that 30 is 1.

This value is assigned to the shell variable b.

The confusion may be caused by the fact that the original author used the same variable name for the shell:

benchmark=30;gr...

as he/she did inside awk:

awk -vbenchmark=$benchmark

which assigns the value of the shell variable benchmark to the awk variable benchmark.

Once awk has this value (30 in this case), awk checks that the 6th column of your input file wk.txt is greater than this value:

$6 > benchmark

The test, using your example, is therefore the string comparison:

for > 30

which, while legal, doesn't really doesn't make much sense. Is the example input file a genuine example or just random test?

This evaluates to true, therefore awk prints the whole line to wc -l which counts the number of lines. As you only have one line in your input file, the count of lines where the 6th column is greater that 30 is 1.

This value is assigned to the shell variable b.

The confusion may be caused by the fact that the original author used the same variable name for the shell:

benchmark=30;gr...

as he/she did inside awk:

awk -vbenchmark=$benchmark

which may or may not assign the value of the shell variable benchmark to the awk variable benchmark.

Once awk has this value (30 in this case), awk checks that the 6th column of your input file wk.txt is greater than this value:

$6 > benchmark

The test, using your example, is therefore the string comparison:

for > 30

which, while legal, doesn't really doesn't make much sense. Is the example input file a genuine example or just random test?

This evaluates to true, therefore awk prints the whole line to wc -l which counts the number of lines. As you only have one line in your input file, the count of lines where the 6th column is greater that 30 is 1.

This value is assigned to the shell variable b.

Source Link
garethTheRed
  • 35k
  • 4
  • 101
  • 106

The confusion may be caused by the fact that the original author used the same variable name for the shell:

benchmark=30;gr...

as he/she did inside awk:

awk -vbenchmark=$benchmark

which assigns the value of the shell variable benchmark to the awk variable benchmark.

Once awk has this value (30 in this case), awk checks that the 6th column of your input file wk.txt is greater than this value:

$6 > benchmark

The test, using your example, is therefore the string comparison:

for > 30

which, while legal, doesn't really doesn't make much sense. Is the example input file a genuine example or just random test?

This evaluates to true, therefore awk prints the whole line to wc -l which counts the number of lines. As you only have one line in your input file, the count of lines where the 6th column is greater that 30 is 1.

This value is assigned to the shell variable b.