in reply to command line pipe

From the command line, perl -n -e'/^Station/ and print' *.txt See perlrun for how the -n option produces the loop you want.

That's no pipe, just a glob of input file names.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: command line pipe
by sauoq (Abbot) on Jul 23, 2003 at 05:11 UTC
    perl -n -e'/^Station/ and print' *.txt

    And that's probably how I would do it, however, those who use this common and powerful feature should be aware that there is a very small security risk associated with using the -p or -n switches with a glob on the command line. Don't do it in directories that can hold filenames originating from an untrusted source. Here's a short demo of why that could be bad...

    $ touch '| echo uh oh;#.txt' && perl -n -e0 *.txt && rm '| echo uh oh; +#.txt' uh oh

    I once promised tye that I would try to do my part in spreading the word about this. It isn't at all likely to pose a real threat, but you should be aware of it just the same. For an in-depth discussion on the subject, see Dangerous diamonds!

    -sauoq
    "My two cents aren't worth a dime.";