sed - write remaining input and quit?

I'm an infrequent user of sed. I searched this and other forums and read quite a bit of the O'Reilly book for an answer without luck.

In my script I want sed to write the remainder of the input file and quit if it matches a pattern.

e.g
/Google/

Does anyone have an answer?

thank.

I'm not sure if I understand you correctly.. You want to print contents of a file, until some pattern is matched, and then quit? If so this will do:

sed '/Google/q' file

Hi
If I had understood you correctly:

# cat f1
Welcome to unix forum
Always if possible,
try to provide sample input
and output. It helps us to provide
solutions faster.
Google is my
dream company by the way.
# sed -n '/Google/q;p' f1
Welcome to unix forum
Always if possible,
try to provide sample input
and output. It helps us to provide
solutions faster.
#

Guru.

Thanks for the quick replies.

Sorry for not being clear enough. Hopefully the following helps.

The quit command only provides half of what I want.
/Processed/q

I want the sed script to print the input until it matches the pattern then print the matched input line and the remainder of the input file THEN quit.
Kind of like:
/Processed/wq

There are other editing commands in the sed script which should be executed if matched but if the /Processed/ pattern is matched I want the all of the input printed to the output.

I'm using the /Processed/ pattern to indicate the file has previously been edited. The 'Processed' line gets read in along with some other text the first time the input file is processed. /pattern/r moretext.txt

Because the sed script could be run multiple times over both processed and unprocessed files I don't want the previously processed files to have multiple additions of the moretext.txt file.

thanks.

That sounds like you want to print out every line before the pattern, the line that matches the pattern, and every line after the pattern. In short, `cat file`.

Why don't you post the sed script you're using, some sample input, and the desired output?

Regards,
Alister

---------- Post updated at 05:08 PM ---------- Previous update was at 04:49 PM ----------

Upon re-reading your post, I think what you are trying to do is print input lines in a loop so that other sed commands are not executed. If so, perhaps this may be helpful:

$ jot 10
1
2
3
4
5
6
7
8
9
10

$ jot 10 | sed -f skip.sed 
1: s command executed
2: s command executed
3: s command executed
4: s command executed
5
6
7
8
9
10

$ cat skip.sed 
/5/ {
    :pr
    n
    b pr
}

s/.*/&: s command executed/

Alister, your skip.sed does exactly what I need. thanks.

Thanks to everyone else for their time.

ps: I still think 'wq' might have been a natural command to have in sed.