Join David D. Levine for an in-depth discussion in this video Solution: Convert first three words of each line to all caps, part of SED Essential Training.
- The challenge is to write a SED script…to change the first three words…of each line to all caps,…using the hold buffer and the y command.…Here's one possible solution.…First, we'll change a space to a #…the third time we find it on the line.…The # will act as a marker to divide the first three words…from the rest of the line in the following steps.…Next, we'll use an h command…to copy the modified line into the hold buffer.…Now we'll change that #,…followed by anything up to the end of the line,…with nothing.…
This second s command deletes the #…and everything after it.…This leaves only the first three words in the pattern space,…while the whole line remains in the hold buffer.…Now we'll use a y command,…to change all the letters in the alphabet,…a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p,…q, r, s, t, u, v, w, x, y, z,…to their uppercase equivalents,…A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,…Q, R, S, T, U, V, W, X, Y, and Z.…
It's too bad that you can't use ranges…with the y command, but you can't.…So this y command changes all the lowercase letters…
AuthorDavid D. Levine
- Understanding input, output, files, and pipes
- Modifying the "s" command
- Using character classes and quantifiers
- Controlling printing
- Reading and writing files
- Appending, inserting, and editing entire lines
- Writing programs in SED
- Using advanced programming commands
Skill Level Intermediate
1. Sed Command-Line Basics
2. Regular Expressions
Using & and \n5m 34s
3. Sed Command-Line Flags
4. More sed Commands
5. Writing Programs in sed
Exiting with "q" and "d"3m 5s
6. Advanced Programming Concepts
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.