Transcript from the "Q&A: Watch and Weather" Lesson
>> James: David shared on Mac, print the date of Easter.
>> Speaker 2: Nice.
>> James: It works on my computer too. [LAUGH] What, I don't even know about ncat. This is the thing. Even if you're using command line for 15 years, stuff like this still constantly comes by. Some command that's already on your system, that you never knew about.
[00:00:26] Like ncow, that I'd never heard of before. [LAUGH] A command that seems to be specifically to determine the date of Easter. All right.
>> Speaker 2: Somebody had to use ncow, it looks like.
>> James: Yeah, yeah. All right.
>> Speaker 2: That's the reason why Bash was actually created. No, reborn.
>> James: Somebody else has a cool one in the chat, it's watch-n30. Page you want to visit. It's cool wait to every 30 seconds print out the status of something. That'd be good if you could find the URL that will print out the temperature, or you could even find some Noah webpage that has the temperature in it.
[00:01:17] There may be other garbage, and you could filter it with and stuff to just print out the temperature. And then you can use the arithmetic expressions to convert from Fahrenheit to Celsius or vice versa or something fun like that. That would be a fun little project if someone wants to figure that out.
>> Speaker 2: How about anybody in the room, have you learned anything? M = commands.
>> Speaker 3: I just put mine in the chat. Just [COUGH] something I did a lot when I was doing backend development. Monitoring logs and then using tail -f. Because it opens up the end of the file and then as the log gets appended to, you can kind of see it and scroll up in your screen.
>> James: Yeah, why don't I show people how that -f works. Because that's really handy too for logging and stuff. So here we have our hello.txt, and so this tail command is just like, it's still open, so it's just waiting to see if anything else is written to that file.
[00:02:28] So if I append some more data to hello.txt, you see it in the command, so different scripts on your system can be running. Or maybe I'll do something a little bit tricky here and I'll make a little watch command that every five seconds will echo the dates. Just echo the date command and maybe the,
>> James: T, right. So this should print out the current time every five seconds to hello.txt. So here we go, there's the first one, and there's the second one.
>> James: So tail -f, pretty useful.
>> James: Anything else? Cool, someone has the weather print out with the curl command, pretty good.
[00:03:30] Paste that one in. Woah [LAUGH] yeah, dude, and this terminal, zoom out of it. Wow, that's something else. You could parse out the temperature, maybe. If I do head -n3. Right, so that progress bar, you can get rid of with -s, curl -s. I guess it's on the fourth line.
[00:04:03] So if you do the head to get the first four lines, and then you do tail to back up one line, you'll get the fourth line. Which has the temperature in it. You can ignore that field writing body. If you want another hack to get rid of that, you can do,
>> James: You can do that magical incantation, 2>&1 which basically copies, sorry, not &1, but you can pipe a standard error which is another kind of thing that's related to standard out, but it's where like spamming messages go [LAUGH]. You can just put into the bin and that way you don't have to see it.
[00:04:43] So there we go. Now we just get the temperature and we can do something like cut out everything that's not a digit. Or I guess E on Mac would be what you would use. I wonder if that works in Linux. Just replace that with nothing. So it should be 51 55.
[00:05:01] But in my case on Linux, I have to use -r or I guess not. Maybe I'll have to do it this way. Woah, weird. Okay, I guess there is a lot of other numbers there. Anyways, if any of you wanna tackle using that weather thing, if you wanna scrape out the temperature from it, that's okay.
[00:05:25] Yeah, question.
>> Speaker 2: Yeah, people are asking if you found a good use for the wall command besides just chatting with other users.
>> James: No, I guess if you had a system script that you want to alert you of critical things, it might be good for that. But I wouldn't do that, that's spammy.
[00:05:45] [LAUGH] It's mostly just used to annoy other users on the system.
>> James: Okay, so someone wanted to see the xargs example. Let me put that back up real fast. It's somewhere in my History. Also, there's a history command. So if you want to see what commands you've typed, you can type history and you can parse that if you like, with grep and whatever.
[00:06:17] So, if I do grep xargs, I see, here we go. So this is my xargs example.