summaryrefslogtreecommitdiff
blob: fd7fe3b169816c0562c75056b9269caed47db48a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2011-09-05 14:11+0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):6
msgid "Sed by example, Part 2"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(author:title):8
msgid "Author"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(mail:link):9
msgid "drobbins@gentoo.org"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(mail):9
msgid "Daniel Robbins"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(abstract):12
msgid "Sed is a very powerful and compact text stream editor. In this article, the second in the series, Daniel shows you how to use sed to perform string substitution; create larger sed scripts; and use sed's append, insert, and change line commands."
msgstr ""

#. The original version of this article was published on IBM developerWorks,
#. and is property of Westtech Information Services. This document is an updated
#. version of the original article, and contains various improvements made by the
#. Gentoo Linux Documentation team
#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(version):24
msgid "1.2"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(date):25
msgid "2005-10-09"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):28
msgid "How to further take advantage of the UNIX text editor"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):30
msgid "Substitution!"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):33
msgid "Let's look at one of sed's most useful commands, the substitution command. Using it, we can replace a particular string or matched regular expression with another string. Here's an example of the most basic use of this command:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):39
msgid "Most basic use of substitution command"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):39
#, no-wrap
msgid "\n$ <i>sed -e 's/foo/bar/' myfile.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):43
msgid "The above command will output the contents of myfile.txt to stdout, with the first occurrence of 'foo' (if any) on each line replaced with the string 'bar'. Please note that I said first occurrence on each line, though this is normally not what you want. Normally, when I do a string replacement, I want to perform it globally. That is, I want to replace all occurrences on every line, as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):52
msgid "Replacing all the occurences on every line"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):52
#, no-wrap
msgid "\n$ <i>sed -e 's/foo/bar/g' myfile.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):56
msgid "The additional 'g' option after the last slash tells sed to perform a global replace."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):61
msgid "Here are a few other things you should know about the <c>s///</c> substitution command. First, it is a command, and a command only; there are no addresses specified in any of the above examples. This means that the <c>s///</c> command can also be used with addresses to control what lines it will be applied to, as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):69
msgid "Specifying lines command will be applied to"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):69
#, no-wrap
msgid "\n$ <i>sed -e '1,10s/enchantment/entrapment/g' myfile2.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):73
msgid "The above example will cause all occurrences of the phrase 'enchantment' to be replaced with the phrase 'entrapment', but only on lines one through ten, inclusive."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):79
msgid "Specifying more options"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):79
#, no-wrap
msgid "\n$ <i>sed -e '/^$/,/^END/s/hills/mountains/g' myfile3.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):83
msgid "This example will swap 'hills' for 'mountains', but only on blocks of text beginning with a blank line, and ending with a line beginning with the three characters 'END', inclusive."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):89
msgid "Another nice thing about the <c>s///</c> command is that we have a lot of options when it comes to those <c>/</c> separators. If we're performing string substitution and the regular expression or replacement string has a lot of slashes in it, we can change the separator by specifying a different character after the 's'. For example, this will replace all occurrences of <path>/usr/local</path> with <path>/usr</path>:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):98
msgid "Replacing all the occurences of one string with another one"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):98
#, no-wrap
msgid "\n$ <i>sed -e 's:/usr/local:/usr:g' mylist.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(note):102
msgid "In this example, we're using the colon as a separator. If you ever need to specify the separator character in the regular expression, put a backslash before it."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):111
msgid "Regexp snafus"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):114
msgid "Up until now, we've only performed simple string substitution. While this is handy, we can also match a regular expression. For example, the following sed command will match a phrase beginning with '&lt;' and ending with '&gt;', and containing any number of characters inbetween. This phrase will be deleted (replaced with an empty string):"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):122
msgid "Deleting specified phrase"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):122
#, no-wrap
msgid "\n$ <i>sed -e 's/&lt;.*&gt;//g' myfile.html</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):126
msgid "This is a good first attempt at a sed script that will remove HTML tags from a file, but it won't work well, due to a regular expression quirk. The reason? When sed tries to match the regular expression on a line, it finds the longest match on the line. This wasn't an issue in my previous sed article, because we were using the <c>d</c> and <c>p</c> commands, which would delete or print the entire line anyway. But when we use the <c>s///</c> command, it definitely makes a big difference, because the entire portion that the regular expression matches will be replaced with the target string, or in this case, deleted. This means that the above example will turn the following line:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):138
msgid "Sample HTML code"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):138
#, no-wrap
msgid "\n&lt;b&gt;This&lt;/b&gt; is what &lt;b&gt;I&lt;/b&gt; meant.\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):142
msgid "Into this:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):146
msgid "Not desired effect"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):146
#, no-wrap
msgid "\nmeant.\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):150
msgid "Rather than this, which is what we wanted to do:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):154
msgid "Desired effect"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):154
#, no-wrap
msgid "\nThis is what I meant.\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):158
msgid "Fortunately, there is an easy way to fix this. Instead of typing in a regular expression that says \"a '&lt;' character followed by any number of characters, and ending with a '&gt;' character\", we just need to type in a regexp that says \"a '&lt;' character followed by any number of non-'&gt;' characters, and ending with a '&gt;' character\". This will have the effect of matching the shortest possible match, rather than the longest possible one. The new command looks like this:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):168
#, no-wrap
msgid "\n$ <i>sed -e 's/&lt;[^&gt;]*&gt;//g' myfile.html</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):172
msgid "In the above example, the '[^&gt;]' specifies a \"non-'&gt;'\" character, and the '*' after it completes this expression to mean \"zero or more non-'&gt;' characters\". Test this command on a few sample html files, pipe them to more, and review their results."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):182
msgid "More character matching"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):185
msgid "The '[ ]' regular expression syntax has some more additional options. To specify a range of characters, you can use a '-' as long as it isn't in the first or last position, as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):191
msgid "Specifying a rangle of characters"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):191
#, no-wrap
msgid "\n'[a-x]*'\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):195
msgid "This will match zero or more characters, as long as all of them are 'a','b','c'...'v','w','x'. In addition, the '[:space:]' character class is available for matching whitespace. Here's a fairly complete list of available character classes:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(th):205
msgid "Character class"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(th):206
msgid "Description"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):209
msgid "[:alnum:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):210
msgid "Alphanumeric [a-z A-Z 0-9]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):213
msgid "[:alpha:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):214
msgid "Alphabetic [a-z A-Z]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):217
msgid "[:blank:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):218
msgid "Spaces or tabs"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):221
msgid "[:cntrl:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):222
msgid "Any control characters"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):225
msgid "[:digit:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):226
msgid "Numeric digits [0-9]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):229
msgid "[:graph:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):230
msgid "Any visible characters (no whitespace)"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):233
msgid "[:lower:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):234
msgid "Lower-case [a-z]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):237
msgid "[:print:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):238
msgid "Non-control characters"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):241
msgid "[:punct:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):242
msgid "Punctuation characters"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):245
msgid "[:space:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):246
msgid "Whitespace"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):249
msgid "[:upper:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):250
msgid "Upper-case [A-Z]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):253
msgid "[:xdigit:]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(ti):254
msgid "hex digits [0-9 a-f A-F]"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):258
msgid "It's advantageous to use character classes whenever possible, because they adapt better to nonEnglish speaking locales (including accented characters when necessary, etc.)."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):267
msgid "Advanced substitution stuff"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):270
msgid "We've looked at how to perform simple and even reasonably complex straight substitutions, but sed can do even more. We can actually refer to either parts of or the entire matched regular expression, and use these parts to construct the replacement string. As an example, let's say you were replying to a message. The following example would prefix each line with the phrase \"ralph said: \":"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):278
msgid "Prefixing each line with certain string"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):278
#, no-wrap
msgid "\n$ <i>sed -e 's/.*/ralph said: &amp;/' origmsg.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):282
msgid "The output will look like this:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):286 ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):355 ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):483
msgid "Output of the above command"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):286
#, no-wrap
msgid "\nralph said: Hiya Jim,\nralph said:\nralph said: I sure like this sed stuff!\nralph said:\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):293
msgid "In this example, we use the '&amp;' character in the replacement string, which tells sed to insert the entire matched regular expression. So, whatever was matched by '.*' (the largest group of zero or more characters on the line, or the entire line) can be inserted anywhere in the replacement string, even multiple times. This is great, but sed is even more powerful."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):304
msgid "Those wonderful backslashed parentheses"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):307
msgid "Even better than '&amp;', the <c>s///</c> command allows us to define regions in our regular expression, and we can refer to these specific regions in our replacement string. As an example, let's say we have a file that contains the following text:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):314
msgid "Sample text"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):314
#, no-wrap
msgid "\nfoo bar oni\neeny meeny miny\nlarry curly moe\njimmy the weasel\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):321
msgid "Now, let's say we wanted to write a sed script that would replace \"eeny meeny miny\" with \"Victor eeny-meeny Von miny\", etc. To do this, first we would write a regular expression that would match the three strings, separated by spaces:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):327
msgid "Matching regular expression"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):327
#, no-wrap
msgid "\n'.* .* .*'\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):331
msgid "There. Now, we will define regions by inserting backslashed parentheses around each region of interest:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):336
msgid "Defining regions"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):336
#, no-wrap
msgid "\n'\\(.*\\) \\(.*\\) \\(.*\\)'\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):340
msgid "This regular expression will work the same as our first one, except that it will define three logical regions that we can refer to in our replacement string. Here's the final script:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):346
msgid "Final script"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):346
#, no-wrap
msgid "\n$ <i>sed -e 's/\\(.*\\) \\(.*\\) \\(.*\\)/Victor \\1-\\2 Von \\3/' myfile.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):350
msgid "As you can see, we refer to each parentheses-delimited region by typing '\\x', where x is the number of the region, starting at one. Output is as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):355
#, no-wrap
msgid "\nVictor foo-bar Von oni\nVictor eeny-meeny Von miny\nVictor larry-curly Von moe\nVictor jimmy-the Von weasel\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):362
msgid "As you become more familiar with sed, you will be able to perform fairly powerful text processing with a minimum of effort. You may want to think about how you'd have approached this problem using your favorite scripting language -- could you have easily fit the solution in one line?"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):372
msgid "Mixing things up"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):375
msgid "As we begin creating more complex sed scripts, we need the ability to enter more than one command. There are several ways to do this. First, we can use semicolons between the commands. For example, this series of commands uses the '=' command, which tells sed to print the line number, as well as the <c>p</c> command, which explicitly tells sed to print the line (since we're in '-n' mode):"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):384
msgid "First method, semicolons"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):384
#, no-wrap
msgid "\n$ <i>sed -n -e '=;p' myfile.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):388
msgid "Whenever two or more commands are specified, each command is applied (in order) to every line in the file. In the above example, first the '=' command is applied to line 1, and then the <c>p</c> command is applied. Then, sed proceeds to line 2, and repeats the process. While the semicolon is handy, there are instances where it won't work. Another alternative is to use two -e options to specify two separate commands:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):397
msgid "Second method, multiple -e"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):397
#, no-wrap
msgid "\n$ <i>sed -n -e '=' -e 'p' myfile.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):401
msgid "However, when we get to the more complex append and insert commands, even multiple '-e' options won't help us. For complex multiline scripts, the best way is to put your commands in a separate file. Then, reference this script file with the -f options:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):408
msgid "Third method, external file with commands"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):408
#, no-wrap
msgid "\n$ <i>sed -n -f mycommands.sed myfile.txt</i>\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):412
msgid "This method, although arguably less convenient, will always work."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):419
msgid "Multiple commands for one address"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):422
msgid "Sometimes, you may want to specify multiple commands that will apply to a single address. This comes in especially handy when you are performing lots of <c>s///</c> to transform words or syntax in the source file. To perform multiple commands per address, enter your sed commands in a file, and use the '{ }' characters to group commands, as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):430
msgid "Entering multiple commands per address"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):430
#, no-wrap
msgid "\n1,20{\n        s/[Ll]inux/GNU\\/Linux/g\n        s/samba/Samba/g\n        s/posix/POSIX/g\n}\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):438
msgid "The above example will apply three substitution commands to lines 1 through 20, inclusive. You can also use regular expression addresses, or a combination of the two:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):444
msgid "Combination of both methods"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):444
#, no-wrap
msgid "\n1,/^END/{\n        s/[Ll]inux/GNU\\/Linux/g \n        s/samba/Samba/g \n        s/posix/POSIX/g \n       p\n}\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):453
msgid "This example will apply all the commands between '{ }' to the lines starting at 1 and up to a line beginning with the letters \"END\", or the end of file if \"END\" is not found in the source file."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):462
msgid "Append, insert, and change line"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):465
msgid "Now that we're writing sed scripts in separate files, we can take advantage of the append, insert, and change line commands. These commands will insert a line after the current line, insert a line before the current line, or replace the current line in the pattern space. They can also be used to insert multiple lines into the output. The insert line command is used as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):473
msgid "Using the insert line command"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):473
#, no-wrap
msgid "\ni\\\nThis line will be inserted before each line\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):478
msgid "If you don't specify an address for this command, it will be applied to each line and produce output that looks like this:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):483
#, no-wrap
msgid "\nThis line will be inserted before each line\nline 1 here\nThis line will be inserted before each line\nline 2 here\nThis line will be inserted before each line\nline 3 here\nThis line will be inserted before each line\nline 4 here\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):494
msgid "If you'd like to insert multiple lines before the current line, you can add additional lines by appending a backslash to the previous line, like so:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):499
msgid "Inserting multiple lines before the current one"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):499
#, no-wrap
msgid "\ni\\\ninsert this line\\\nand this one\\\nand this one\\\nand, uh, this one too.\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):507
msgid "The append command works similarly, but will insert a line or lines after the current line in the pattern space. It's used as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre:caption):512
msgid "Appending lines after the current one"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(pre):512
#, no-wrap
msgid "\na\\\ninsert this line after each line.  Thanks! :)\n"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):517
msgid "On the other hand, the \"change line\" command will actually replace the current line in the pattern space, and is used as follows:"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):522
msgid "Because the append, insert, and change line commands need to be entered on multiple lines, you'll want to type them in to text sed scripts and tell sed to source them by using the '-f' option. Using the other methods to pass commands to sed will result in problems."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):532
msgid "Next time"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(p):535
msgid "Next time, in the final article of this series on sed, I'll show you lots of excellent real-world examples of using sed for many different kinds of tasks. Not only will I show you what the scripts do, but why they do what they do. After you're done, you'll have additional excellent ideas of how to use sed in your various projects. I'll see you then!"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):548
msgid "Resources"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(title):550
msgid "Useful links"
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(li):554
msgid "Read Daniel's other sed articles from developerWorks: Common threads: Sed by example, <uri link=\"l-sed1.xml\">Part 1</uri> and <uri link=\"l-sed3.xml\">Part 3</uri>."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(li):559
msgid "Check out Eric Pement's excellent <uri link=\"http://sed.sourceforge.net/sedfaq.html\">sed FAQ</uri>."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(li):564
msgid "You can find the sources to sed at <uri>ftp://ftp.gnu.org/pub/gnu/sed</uri>."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(li):568
msgid "Eric Pement also has a handy list of <uri link=\"http://sed.sourceforge.net/sed1line.txt\">sed one-liners</uri> that any aspiring sed guru should definitely look at."
msgstr ""

#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(li):573
msgid "If you'd like a good old-fashioned book, <uri link=\"http://www.oreilly.com/catalog/sed2/\">O'Reilly's sed &amp; awk, 2nd Edition</uri> would be wonderful choice."
msgstr ""

#. Place here names of translator, one per line. Format should be NAME; ROLE; E-MAIL
#: ../../gentoo/xml/htdocs/doc/en/articles/l-sed2.xml(None):0
msgid "translator-credits"
msgstr ""