You're missing the multicolumn text file as an input to awk, so it doesn't know what to operate on.
Your awk code doesn't have a print statement, so nothing will be printed. So your result of 1 or 2 is a bit surprising. If it printed something, then the (desired) result for the given contents of hdr array should be 2 and 4, for the two elements as indicated.
Your pattern check $0 ~ col is quite unspecific, it will trigger on any occurrence of the pattern also later in the file - you may want to confine the action to the first line only.
It's not clear what the heading, colhdr, and wanted variables / arrays are meant for, as they aren't used anywhere.
You want a "word in column header that fully matches the word not partially", so why use the index function in lieu of an equals operator?
Hi,
I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file.
Ex:
$ cat "sample.log"
I am searching for a word which is present in this file
We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Hi All,
I have a XML file which is looks like as below. <<please see the attachment >>
<?xml version="1.0" encoding="UTF-8"?>
<esites>
<esite>
<name>XXX.com</name>
<storeId>10001</storeId>
<module>
... (4 Replies)
Hi, I have a file with +/- 13000 lines and 4 column. I need to search the 3rd column for a word that begins with "SAP-" and move/skip it to the next column (4th). Because the 3rd column need to stay empty.
Thanks in advance.:)
89653 36891 OTR-60 SAP-2
89653 36892 OTR-10 SAP-2... (2 Replies)
I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word "description" excluding weird characters like $&lmp and without html tags in the new file output.txt. Help me. Thanx in advance. I have attached the input... (4 Replies)
I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word description excluding weird characters like $$#$#@$#@***$# and without html tags in the new file output.txt. Help me. Thanx in advance.
My final goal is to... (11 Replies)
I have a data in a file like this
1 praveen bmscollege
2 shishira bnmit
3 parthiva geethamce
I want to search "praveen" using awk command i tried like this but i did not get
awk `$2="praveen" {print $0} ` praveen.lst
can anyone help me solving this problem in... (2 Replies)
Hi, i am new to unix shell scripting and i need a script which would search for a particular word in all the files present in a directory. The output should have the word and file path name. For example: "word" "path name".
Thanks for the reply in adv,:) (3 Replies)
Hi,
I have to search a word in a text file and then I have to delete lines above from the word searched . For eg suppose the file is like this:
Records
P1
10,23423432
,77:1
,234:2
P2
10,9089004
,77:1
,234:2
,87:123
,9898:2
P3
456456
P1
:123,456456546
P2
abc:324234 (2 Replies)
How to search for a word like "computer" in a column (eg: 4th field) of a '***' delimited file and add a column at the end of the record which denotes 'Y' if present and 'N' if not. After this, we need to again check for words like 'Dell' but not 'DellXPS' in 5th field and again add another column... (5 Replies)