Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can variables be used as pattern for awk command?

 
anandkumar biyani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12085
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic