Re: How to printout matching pattern in command line



pechoi@xxxxxxx wrote:
Hi all
I am trying to print out matching pattern at command line. How can I do
it?
my command looks like:

perl -e 'print m/PATTERN/g' filename

It's extranoridinarily difficult to know what you're asking. Could you
possible post some sample input and desired output?

I'm *guessing* that what you want to do is loop through all lines of
filename and print out any that match PATTERN. (Which, near as I can
tell, is just a simple Unix grep command). Is that correct?

perl -ne'print if /PATTERN/' filename

Read up on the -n command line option in: `perldoc perlrun`

Paul Lalli

.



Relevant Pages

  • Re: Opening file($ARGV) with Getopt - failing
    ... > perl mycode.pl -f filename ... The diamond operator will read the end ... and open each filename it finds there for processing. ... operator reads the command line and processes each file name on ...
    (perl.beginners)
  • Re: Changing Uppercase filenames into Lowercase
    ... uppercase filename to a lowercase filename, ... foundfile = f$searchcommand line. ... Based on a command procedure by Willem Grooters which was ...
    (comp.os.vms)
  • Re: Pass command line file name parameter
    ... Then the document class has a copy of the filename, ... No need to access the original command line at all. ... want the user to see all the labels as they would be printed. ... filename or any other variable of your CWinApp class. ...
    (microsoft.public.vc.mfc)
  • Re: CStdioFile::Open gives error "No error occurred"
    ... I would avoid GetErrorMessage and just use FormatMessage on the error code itself, ... presume this is *not* the filename you planned to open, so why are you using m_lpCmdLine? ... there is a serious question here as to whether or not the command line has any ... Use the debugger, it is a very useful tool. ...
    (microsoft.public.vc.mfc)
  • Re: Cannot delete directory
    ... "Glenn" wrote in message ... > in a command window. ... >>window is a "normal" window. ... >>be a valid 8.3 filename - even if it has somehow been ...
    (microsoft.public.win2000.file_system)