This is topic Need awk search Command substitution help in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=039469

Posted by Blayne Bradley (Member # 8565) on :
 
So inorder to check to see if $x already exists in /Pract.file

I'm trying to do awk '/$x/' Pract and if it works should display all lines that are in the variable "x" which is echo x="`echo $y | cut -d' ' -f2 | cut -c1-3``echo $y | cut -c1-3`"

However when I run it it does this:

[cs326_2@Linux2.cs] x="`echo $y | cut -d' ' -f2 | cut -c1-3``echo $y | cut -c1-3`"


[cs326_2@Linux2.cs] awk '/$x/' Pract
[cs326_2@Linux2.cs]

IT ran, there's no syntax error but its not displaying anything, in theory I want it to display lines of text allowing me to do a conditional statement in regarding if the name already exists. Whats wrong?

(Bash shell I believe)
 
Posted by Dav (Member # 8217) on :
 
Without offering to do your hw for you, here's a little pointer: Single quotes don't allow variable substitution in the bash shell. So, your '/$x/' is trying to match on the end of line, *followed* by x on the same line, which of course is impossible.

Beyond that, it's not clear to me what you're trying to do...
 
Posted by fugu13 (Member # 2859) on :
 
You didn't look at my example awk command from before, either [Razz] .
 
Posted by Blayne Bradley (Member # 8565) on :
 
huh? for the split I looked at, for assigning a number I looked at, but I dont think I recal how to get output/assign a variable.
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2