Amit Agarwal

Linux and Photography Blog
helplanguage
Screenshot of a sample Bash session.
Image via Wikipedia

| perl -n -e 'print "$_" if 1 ... /<regex>/;# This command line will display the output of , from the first line of output, until the first time it sees a pattern matching .

You could specify the regex pattern /^$/ to look for the first blank line,

or /^foobar/ to look for the first line that starts with the word foobar.

by David Winterbottom (codeinthehole.com)


URL: http://feedproxy.google.com/~r/Command-line-fu/~3/Ie99mgx_Pfw/display-the-output-of-a-command-from-the-first-line-until-the-first-instance-of-a-regular-expression.

There are couple of other ways you can do so, like using sed, awk.

<command> |sed –quiet ‘/svn_/,$ !p’

Reblog this post [with Zemanta]

Enter Your Mail Address

Display the output of a command from the first line until the first instance of a regular expression.
Hot:sun Display the output of a command from the first line until the first instance of a regular expression.sun Display the output of a command from the first line until the first instance of a regular expression.sun Display the output of a command from the first line until the first instance of a regular expression.sun dark Display the output of a command from the first line until the first instance of a regular expression.sun dark Display the output of a command from the first line until the first instance of a regular expression.

You are welcome to my blog. Please feel free to share your Good or Bad experiences with me through comment or through email.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • blogmarks
  • Blogosphere News
  • co.mments
  • HelloTxt
  • Ping.fm
  • Reddit
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Add to favorites
  • BlinkList
  • Diigo
  • email
  • Identi.ca
  • LinkedIn
  • Live
  • MyShare
  • MySpace
  • PDF
  • SheToldMe
  • Slashdot
  • Socialogs
  • Tumblr

related post

Technorati Tags: , , , , , ,

Display the output of a command from the first line until the first instance of a regular expression.

Facebook comments:

1 Comment »

  1. Excellent and very thoughtful post! I really appreciate the time and effort you put in every single one of your posts, and finally decided to drop a comment on one of them! If you got some extra time on your hands and looking to improve your search engine rankings in the new Google Caffeine search results take a look at the Google Caffeine eBook…

    Anyways, good luck on your blog, and feel free to check out : Google Caffeine

    Thanks so much!

    All the best,
    Dino Vedo

RSS feed for comments on this post. TrackBack URL

Leave a comment



IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

What is 10 + 15 ?
Please leave these two fields as-is:
tour

© 2010 Amit Agarwal | Entries (RSS) and Comments (RSS) | Valid CSS 2.1 Valid XHTML 1.0 Transitional

Powered by Wordpress 3.0, design by Abel, handcrafted by Abel County Laboratories, based on Wsg Standards Wsg Standards

conditions

Switch to our mobile site

Page optimized by WP Minify WordPress Plugin