darth_vector
September 18th, 2006, 11:49 PM
i am trying to write a bash script that requires the kind of functionality shown below:#!/bin/bash
FILE=$1
COL_TO_PRINT=$2
cat $FILE | awk '{print $COL_TO_PRINT}'and for the life of me I can't work out how to do it. of course doing an awk '{print $2}'wont work because awk interprets this as the second column of the file, not the second argument of the script.
any help would be appreciated...
FILE=$1
COL_TO_PRINT=$2
cat $FILE | awk '{print $COL_TO_PRINT}'and for the life of me I can't work out how to do it. of course doing an awk '{print $2}'wont work because awk interprets this as the second column of the file, not the second argument of the script.
any help would be appreciated...