Check out a free preview of the full Introduction to Bash, VIM & Regex course
The "More Curl and Grep" 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 reviews in more detail curl and grep.
Transcript from the "More Curl and Grep" Lesson
[00:00:00]
>> James Halliday: We talked about curl already. There's a lot of different options to curl. I really recommend that if you get the time and you wanna go through the manual for curl, it's well worth your time. Because you can do all kinds of things with curl, like sending post requests.
[00:00:16]
If you're running HTTP servers at all or if you need to interface with HTTP APIs. You can do things, like a curl- X POST, which will send a post request. And you can do something, like do a file upload with T and T- from standard in. So some API service you're running locally, like that, so you can do all kinds of fun stuff.
[00:00:42]
Or you can do a form upload with -d. And that lets you set different fields. So user=whatever -d hello=blah, to d. So curl is certainly worth your time. I don't wanna get too much into it here. I will get more into it on one of the other workshops about the networking.
[00:01:08]
All of the kinds of things that you can do with curl. But curl is very excellent to have in your tool belt of things that you can kinda keep on the top of your head, cuz it just comes up all the time dealing with HTTP servers. So one fun thing you can do with curl and GitHub is GitHub has a special URL.
[00:01:30]
So you can take anyone's GitHub account name and go to github.com/substack, for example. Then add .keys at the end of that. And you'll get a list of all of their public keys. So here we've got a bunch of output, like an old RSA key that I guess they still have on GitHub.
[00:01:51]
We have some ed25519 keys, so I can use grep to pull those out.
>> James Halliday: Here, we can see what those look like. We can use some of the other commands that we've been dealing with, like head, to get the first one.
>> James Halliday: We can even use sed to cut out the first bit.
[00:02:11]
Or actually, I would use awk for that. I won't go into that, but you can do things, like this with awk, to print out the second field in the result. Very handy little tools that you kinda have to know about them. And it's sort of not obvious what they're even called or what they're for.
[00:02:29]
But they're already installed on your system, which is really useful. I'll talk a bit about grep. And I'm gonna be going a lot more into grep and sed in the regular expression section that's coming up. But you can use it to search for patterns. So here, I searched for the pattern beginning, like starting from the beginning of the language is what a caret means.
[00:02:53]
Searching for the string ssh-ed25519 to pull out my 25519 keys not the RSA keys or the other ones.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops