Question: During the startup of a Linux AMI, I would like to download some data (like the sun java libraries and some proprietary software) from an S3 bucket while initializing my EC2 connection. I notice that one way to do this is to use s3cmd. BUT, how do I get the configuration file for s3cmd .s3cfg from S3?

Also, let me also know if there is a better way to connect to S3 storage during init.

Thanks!

Answer: 
Why not do it entirely in perl, rather than using awk? You should be able open the file, read in each line and print it out if the regex matches. Regular expressions are one of perls best strengths, why not take advantage of them directly rather than trying to call awk?

The only advantage I see to using awk is that you would have to manually list all of the \*\_Codes.txt files, but that shouldn't be too difficult in perl.

The easiest way to do it in perl, assuming you have a line of text, is simply to run the regex 3 times, one for each portion you're trying to match. For exmaple, if you want to match `204`, `test` and `leg` you should be able to do

```
if (($line =~ m/ 204/i) && ($line =~ m/ test/i) && ($line =~ m/ leg/i)){
    print $line;
}

```
While Skolor's answer is completely appropriate, here's a slightly different approach, making use of the [smart match operator](http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail) (which is available in Perl version 5.10 or greater). If the lines of your text file are really long and if you don't have a lot of words to check against the lines, this might be a quicker approach (emphasis on "might").

```
use strict;
use warnings;

my @query_words=qw(204 test leg);

open(my $read,"<","input_file") or die $!;

while(<$read>)
{
  chomp; #get rid of trailing newline
  my @words=split(/\s+/,$_); #split on spaces to get actual words

  foreach my $q (@query_words)
  {
    if($q~~@words) #If we have a match, print and exit the loop.
    {
      print "$_\n";
      last;
    }
  }
}

close($read);

```