FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Need awk search Command substitution help

   
Author Topic: Need awk search Command substitution help
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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)

IP: Logged | Report this post to a Moderator
Dav
Member
Member # 8217

 - posted      Profile for Dav           Edit/Delete Post 
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...

Posts: 120 | Registered: Jun 2005  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
You didn't look at my example awk command from before, either [Razz] .
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.
IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

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