awk match whole word using a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk match whole word using a variable
# 8  
Old 08-20-2013
You didn't read Jotne's post.
# 9  
Old 08-20-2013
Quote:
Originally Posted by RudiC
You didn't read Jotne's post.
What did I miss there?
# 10  
Old 08-20-2013
How to read variable in to awk!!!
You are searching for string <pinName>, not for an varibale named pinName.
Use option -v or variable behind awk
# 11  
Old 08-20-2013
Quote:
Originally Posted by Jotne
How to read variable in to awk!!!
Sorry, but I must have not explained myself correctly.
I don't need to read a variable to awk.
The variable is already an awk variable.
Look at the code I posted. It is all 'awk' code. No shell involved there.

Thanks.
# 12  
Old 08-20-2013
I do suggest you post your input file, how you like to output to be and how to get there.
This way we can more understand what you are doing.
# 13  
Old 08-20-2013
Quote:
Originally Posted by Jotne
I do suggest you post your input file, how you like to output to be and how to get there.
This way we can more understand what you are doing.
It is a little more complicated than that.
I am not making small manipulations on texts.
I tried to narrow it down to the relevant part.

I did some search and I realized there is no way to use a variable
inside a regular expression, so I worked around the problem.

Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to search for a word in column header that fully matches the word not partially in awk?

I have a multicolumn text file with header in the first row like this The headers are stored in an array called . which contains I want to search for each elements of this array from that multicolumn text file. And I am using this awk approach for ii in ${hdr} do gawk -vcol="$ii" -F... (1 Reply)
Discussion started by: Atta
1 Replies

2. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

Replacing the first word if the word three match

Dear ALL, I have sample file : IDcentos-forum,bash,linuxCentOS,GNome IEfedora-milis,cli,linuxRedhat,KDE IRfreebsd-milis,aix,unixbsd,pyton required output: centos,bash,linuxCentOS,GNome fedora,cli,linuxRedhat,KDE freebsd,aix,unixbsd,pyton Can you help me pls.. (1 Reply)
Discussion started by: gnulyn
1 Replies

4. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies

5. Shell Programming and Scripting

awk match shell variable that contains special characters?

How to match a shell variable that contains parenthesis (and other special characters like "!") file.txt contains: Charles Dickens Matthew Lewis (writer) name="Matthew Lewis (writer)"; awk -v na="$name" ' $0 ~ na' file.txt Ideally this would match $name in file.txt (in this... (3 Replies)
Discussion started by: Mid Ocean
3 Replies

6. Shell Programming and Scripting

Print a word after a match

Hi all, I have the below line: 08 03 * * 1-5 XXXXXXXXXXXXX -ENVI LDNFOUAT10 -EXE xxxxxxxx -CONFIG \${xxxxx} -SUBCLASS RESET -START -EXTRAAPPARGS \" -env 38LDNFOUAT10 \" >> /tmp/SRRC_xxxxxxx_start.log.`/usr/bin/date +\%Y\%m\%d` 2>&1 I want to print just one word after the string "-env", in... (7 Replies)
Discussion started by: Cvg
7 Replies

7. Shell Programming and Scripting

Match exact Variable in Awk

I want to match exact string stored in Variable INO and print next two lines. I have written below code which partially matches: awk '/\'$VAR'/{getline; getline; print}' Will be thankful , if somebody can help in to resolve this problem. Please view this code tag video for how to use... (9 Replies)
Discussion started by: nitj
9 Replies

8. Shell Programming and Scripting

Substituting a word by different word in variable

Hello Exprets, I have a requirement where i have to subtitue a word with another word. $eachline| sed 's/*$//' a) $eachline will hold a value a path for example user/oracle/Test_admin/myfolder/bakup/part_bkptemp_part_bkp_repeated/list.txt b) $eachline| sed 's/*$//' will give me the... (3 Replies)
Discussion started by: aks_1902
3 Replies

9. Shell Programming and Scripting

Question on awk for finding the column number using a match word

Hi Guys, Please help me out in my situation of writing a shell script Exampl:I have a output like asnapply 1 2 3 apply_server=1 apply_schema=ASN asnapply 1 2 3 apply_server=2 apply_schema=ASN Now i need output like asnacmd applysever=1 applyschema=ASN stop asnacmd applysever=2... (16 Replies)
Discussion started by: mallak
16 Replies

10. Shell Programming and Scripting

How to match a exact word in a variable ????

Hi All, Str="online maintenance" if then perform some action I know the above comparison is wrong ..... Actually I am very new to this solaris.. I want to check for online in a variable and perform some action based on that How can I do it? (6 Replies)
Discussion started by: vijaysachin
6 Replies
Login or Register to Ask a Question