 As I've said in all the videos in this series, this is a series. There should be an annotation on the screen to the playlist if you haven't watched them already. Check them out. We've been playing with sed and we've been working with it to modify files and the output of files. Today we're going to look at how to use sed, kind of like its head. If you're familiar with the head command, well let's have a quick look here. I can use cat to cat out a file. I'll use my text to file since it's numbered most part. Line 5 doesn't have anything on it. I can say head text to and by default head displays 10 lines which are 10 lines in my file but I can give head if there were more than 10 it would only display the first 10. I can also say dash n and say 5 and it would only, sorry, dash 5 and it would show only the first five lines or the first two lines and we can do this with sed too. Now obviously you know if this is all you're trying to do a head would probably be a better option. It's usually always there but you know as you get more complex things going would said you may want to use it to display only the first part of the line and then modify those with a second part of sed rather than starting a head process and a sed process. It's just two different ways of doing stuff. In fact speaking of two different ways of doing stuff I'm going to show you how to do this in said two different ways. Let's clear the screen here. So what I can do is I can say sed and then inside our quotations our single quotes here although I think you used double quotes too I just tend to use single quotes. We are going to say, well there's already 10 lines in that file so let's just say 4. We want to show 4 and then we can say dollar sign D and of course out here give the name of our file. Let's see if that works and then I'll explain it. Okay so you'll notice that it only displayed the first three lines and if I change this to 5 it will display the first four lines. The reason for this what it's doing and you may be able to guess if you've been watching our series is we're using sed. Now 5 obviously means five lines even though we're only getting four and then we have a dollar sign and the D. Now you should know if you've been following the series that dollar sign means find the end of line. Find basically a new line character kind of a little different but you know end of line find the end of line and then here it's saying D which we know D means delete. So what this is saying is go to line 5 and then any line that has an end of line character which is every line starting at line 5 delete it. So since we're starting at 5 and then we're checking once we get to 5 for end of line we're saying delete 5 as well. So that's one way of doing it. There is an easier way that I'm about to show you but again as we get more complex this will come into use in getting more complex commands so I wanted to show you that. But another way of doing it is simply to say the number lines so if we want to display four lines this time we actually type 4 space Q and once that's saying is said do whatever you're doing until line 4 and then after you get you know you finish line 4 Q means quit. So there we go and of course you can put in you know whatever number you want line 6 line 7. So again this is obviously a simpler answer but we're gonna get a little more into this I think in future tutorials and there's more you can do with this and that's why I wanted to display it. So we'll review these two commands again we're saying said go to line 5 and then delete every line from line 5 and on that's why you only get 4 because we're on line 5 and we're deleting it. This command here is saying said display the first or do whatever but display the first four lines command of the file and then quit. So that's two ways to make said act similar to head and again if you're just trying to display the first certain number lines of file head might be a better option but we can incorporate this as we've seen you can put more than one command in the said so you may want to look at the first four lines you know do something of them and then quit so that's why you kind of need to know this. So and the more you know the the better you're off you are because you know you might come across a situation that requires this. So again I thank you for watching visit my website filmsbychrist.com that's Chris with the K if you're enjoying these videos let me know by liking and commenting below if you have questions technical questions about using said or any other scripting whatever comments are not the best place to put them be sure to visit my IRC channel I'm not always in there there's usually somebody around but you may not get a response right away ask your question hang out see if someone answers it there's also probably a said IRC channel that if we can't help you they might be able to help you but my IRC channel is a great place to hang out learn talk to people if you come in there plan on coming in and hanging out don't come in ask a question then leave it's it's I want you guys to be like part of the community and just hang out and again check out the rest of this playlist filmsbychrist.com that's Chris the K and have a great day