Instructor: In my directory here, I have one file, this cloneelement.js, which I got from the React repository. Let's glance at this file. You see it has a lot of whitespace in it. Let's say that I want to delete all lines that contain empty lines. Let's see how we do that here with sed.
My script will go here, and then I'll pass the file name. Right here, this is the address of the command. This would be a regex that I'm going to leave empty for now, and then, I'm going to use the d command, which stands for delete.
Let's fill in our regex here. To get all empty lines, we're going to do the start operator and then the end-of-line operator, like that, and then d will delete it. Let's run that and see what happens.
You see, it's condensed it a lot. If we want to modify the file, instead of outputting the modifications to stdout, we can use the in-place flag, but no backups. If we run that and then check out our file, we can see that we modified the file in-place. Cool, that worked.
We can also delete line numbers. Let's get the first two lines of cloneElement. If we wanted to delete that first line with the inaudible sign, we could pass 1 as the line number and then the d command. You can see now that empty array thing is the first line.
Another handy one is deleting the last line. To do that, we use the special $ symbol, which sed interprets as the last line of the file. You can see that worked, because we're missing the closing curly brace that was the last line.