aspose file tools
The moose likes Perl and the fly likes can variables be used as pattern for awk command? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Languages » Perl
Reply Bookmark "can variables be used as pattern for awk command?" Watch "can variables be used as pattern for awk command?" New topic
Author

can variables be used as pattern for awk command?

anandkumar biyani
Greenhorn

Joined: Dec 06, 2011
Posts: 9
Hello everyone,

I wanted to know if we can use the variable as a pattern for awk command as shown below:

$c = "Dec Tue";
$log = `awk '/\$c/' in.txt`;
print $log;

I have to search for a pattern in $c occuring in file in.txt.

Thanks in advance.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9948
    
    6

What happened when you tried it?


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: can variables be used as pattern for awk command?
 
Similar Threads
How to read each line from file in Shell script
whats the error!
split function problem in AWK
Inserting character/editing huge file on unix
use of variables in awk to search for pattern from a file