I am working on a shell script which has a lot of SED and AWK commands in it. Now, I am stuck up in a place where i couldn't proceed further.
For example :- If i run the below command. It prints the first column.
awk 'OFS="\t" {print $1;}' finename.txt
But, Is there a way to print a particular column using column name instead of column number. Guess there is no straight forward way to do it, But there should be some trick to do this.
Sample data(tab seperated)
itemNumber Price Mango Apple Bannana
112201 purchased need-to-plan purchased
112202 55 yet-to-buy yet-to-buy purchased
112202 67 need-to-plan purchased purchased
112203 456 need-to-plan need-to-plan need-to-plan
112203 33 need-to-plan yet-to-buy need-to-plan
112204 456 need-to-plan yet-to-buy need-to-plan
112204 yet-to-buy purchased need-to-plan
112205 77 yet-to-buy purchased need-to-plan
112205 99 yet-to-buy purchased yet-to-buy
112206 0 yet-to-buy purchased yet-to-buy