Check out a free preview of the full Introduction to Bash, VIM & Regex course
The "Shorten Lines" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. Here's what you'd learn in this lesson:
James demonstrates the fold command, which is used to shorten long lines.
Transcript from the "Shorten Lines" Lesson
[00:00:00]
>> James Halliday: Another fun little utility to play around with is called fold. So if you wanna format text to do things like word wrapping, you can use the fold command. So for example, going back to Moby Dick for a bit. So if we pull out the first 250 lines of Moby Dick, maybe we wanna format it so that,
[00:00:28]
>> James Halliday: Instead of these really wide columns, or instead of this really wide output, we can have it be formatted a little more narrowly, cuz sometimes that's easier to read. So we can do fold -w 30, and that uses 30 characters of width. And then, it's a little bit annoying, because it actually breaks the output in between words.
[00:00:56]
So if you don't want it to do that, I think it's -sw, yeah, and that will break it on words. Of course, there's already new lines in the file, so it's kind of annoying as well. But you could use a little set expression if you want to kind of cut things up in a better way, and you can format it however you like.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops