awk -v var=value_of_wherever '$1 >= var' input_file
See the following example
#/bin/bash
let i=1
for ((i=1; i<=5; i++)); do # this is also called the C-like loop
echo 'i = ' $i
echo -n 'Now see awk result: '
awk -v test_value=$i '$1 == test_value' data_file
# use -v option in awk to assign the variable $i
# to test_value, which is passed inside the awk
# command inside quotes.
done
See the following example
#/bin/bash
let i=1
for ((i=1; i<=5; i++)); do # this is also called the C-like loop
echo -n 'Now see awk result: '
awk -v test_value=$i '$1 == test_value' data_file
# use -v option in awk to assign the variable $i
# to test_value, which is passed inside the awk
# command inside quotes.
done
留言