# 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.
#
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.
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/