0
I have a data in the file in columns. I want to write a script, which displays the data of the column matching the column heading.
C-1 C-2 C-3 C-4 C-5 C-6 C-7 C-8 C-9
10 30 35 20 9 65 87 30 29
40 32 67 78 30 54 24 21 13
50 43 32 12 43 65 78 67 54
if the user choose to display C-8 column then the out put must be
C-8
30
21
67
I am not sure how to match the column name and print the output using awk.
Thanks, KJ
Thanks for the solution, it works perfectly. Can you please explain what "column=${column:(-1)}" is working. – KumarJohn – 2015-06-17T11:15:57.813
Takes the last character of variable
column
– jcbermu – 2015-06-17T11:18:28.320I made a change to use the *title column` instead of a number – jcbermu – 2015-06-17T11:19:03.020
This works fine if the column numbers are matching what if the column numbers does not match and column name are some text like name, Rollno, this script will not work in that case. – KumarJohn – 2015-06-17T11:26:38.523
If there is not maching, it shows nothing. If text on column is like Rollno for example, change variable
to_remove
on the script. – jcbermu – 2015-06-17T11:37:15.013This is not working, I am getting complete table as the output. – KumarJohn – 2015-06-17T11:43:58.420
Let us continue this discussion in chat.
– jcbermu – 2015-06-17T11:46:02.767I am trying to enter the chat but its taking time – KumarJohn – 2015-06-17T11:53:01.170
@KumarJohn Now you can use any name you want. – jcbermu – 2015-06-17T13:32:35.583