Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: find string in file

by hipowls (Curate)
on Mar 31, 2008 at 09:50 UTC ( #677485=note: print w/replies, xml ) Need Help??

in reply to find string in file

perl -ne'print if /Version +=/' file_name

perl -ne'print if /Version\s*=/' file_name

Updated: Thanks for the corrections;-)

Replies are listed 'Best First'.
Re^2: find string in file
by CountZero (Bishop) on Mar 31, 2008 at 10:06 UTC
    perl -ne'print if /Version\s+=/' file_name
    The character class \s contains all forms of whitespace (such as tabs, ...).


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      ... and both of you failed to notice that "0 or more" translates to *, not + ;-).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://677485]
[choroba]: LanX I miss working in a bank sometimes...
[Corion]: Discipulus: Ooof. Especially yearly things are things I like to automate instead of trying to remember how I did things last year...
[Corion]: And the second rule that I've learned is, that there is no one-off job, so writing a program for it pays off almost immediately. The third rule is to give all my programs numbers and have them reproduce that number in the name of their output files. :)
[Discipulus]: the true part is that also specification change between years.. but well our job is cheap but dont abuse of us.. ;=)
[LanX]: Choroba: do you miss chaos with ties? apply at the US government.. ;)
[ambrus]: Corion: those are good rules.
[ambrus]: Discipulus: oh sure. the input data has different filenames every time I get them.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (14)
As of 2017-03-29 12:12 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (350 votes). Check out past polls.