Gentoo Archives: gentoo-dev

From: Ryan Hill <dirtyepic@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: to patch or sed was -> repoman and checking for correct quoting
Date: Sat, 10 Nov 2007 19:48:52
Message-Id: fh51nv$gih$1@ger.gmane.org
In Reply to: Re: [gentoo-dev] to patch or sed was -> repoman and checking for correct quoting by "William L. Thomson Jr."
1 William L. Thomson Jr. wrote:
2
3 > Now I know some will scream, puke, throw up in their mouth, and so on.
4 > But seems like sed should have an OPTIONAL argument or etc to tell sed
5 > to either fail if it can't make the change anywhere. And/or keep/output
6 > a count of how many things were modified.
7
8 you could use the w flag to the s command.
9
10 `w FILE-NAME'
11 If the substitution was made, then write out the result to the
12 named file. As a GNU `sed' extension, two special values of
13 FILE-NAME are supported: `/dev/stderr', which writes the result to
14 the standard error, and `/dev/stdout', which writes to the standard
15 output.(1)
16
17 dirtyepic@tycho ~/tmp $ cat test
18 this is a test: 12345
19 line 2
20 line 3
21 line 4: 12345
22 dirtyepic@tycho ~/tmp $ sed -i -e 's:12345:54321:w sed.log' test
23 dirtyepic@tycho ~/tmp $ cat test
24 this is a test: 54321
25 line 2
26 line 3
27 line 4: 54321
28 dirtyepic@tycho ~/tmp $ cat sed.log
29 this is a test: 54321
30 line 4: 54321
31 dirtyepic@tycho ~/tmp $ sed -i -e 's:12345:54321:w sed.log' test
32 dirtyepic@tycho ~/tmp $ cat sed.log
33 dirtyepic@tycho ~/tmp $
34
35 or
36
37 dirtyepic@tycho ~/tmp $ sed -i -e 's:12345:54321:w /dev/stdout' test | wc -l
38 2
39
40 --
41 looks like christmas at fifty-five degrees
42 this latitude weakens my knees
43 EFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662 (0xF9A40662)

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies