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

\"Screenshot
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

Know when you will type :q in your term instead of vi(m), the alias will chewed you out.

most simple solution is to alias :q like so:
alias :q=`echo \”This is not vim\”`

but as someone suggested in commandlinefu, you can use tput to put some color and fun into this.
alias :q=\’tput setaf 1; echo >&2 \”this is NOT vi(m) :/\”; tput sgr0\’

Display a block of text with delineated by a start pattern and an end pattern

Taken idea from commandlinefu.com

The command will display a segment from the file from the start pattern to the end pattern.

function viewsegment() { tail -n +`fgrep -n -m 1 "$1" $3 | head -`fgrep -n -m 1 "$2" $3 }
Display a block of text with delineated by a start pattern and an end pattern