The following simple bash script prints the row number (from the file list.txt):
function get_row
{
[[ $1 = 1 ]] && awk '{print $1}' list.txt
[[ $1 = 2 ]] && awk '{print $2}' list.txt
}
get_row 1
get_row 2
But I would like to write it more elegantly.
Is it possible to set $1 as variable as awk '{print $val}',
so that if I call a function as get_row 1, the variable $val gets the value 1?