File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Languages » Perl
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: 11256
    
  16

What happened when you tried it?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
 
subject: can variables be used as pattern for awk command?