yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Terminal Lesson 5


5m read
·Nov 3, 2024

Mad kids online, and today I'm going to be showing you one more terminal trick, and it's actually worth your time. I'm gonna be showing you today how to zip a file into a zip file and how to zip multiple files.

So I'm gonna be demonstrating this to you on my desktop. Let's see my desktop—normal stuff here and some hard drives and stuff. So right now, first of all, I'm gonna make a new document called hi. Inside of this, I'm just gonna type some random stuff.

Now, when my desktop is hot, now we all remember this—how this works. We're gonna zip up hi into a zip contrast file or folder. See, what we're gonna do is we're gonna type zip zip space ./.hideout.zip ./.hi. Let me explain this: zip just zips something. The first parameter, which is ./hideout.zip, is where we're gonna zip, and . means my active directory, like my PWD.

So right now, if I type PWD, I'm in /user/Alex/desktop. That means /user/Alex/desktop, that's what that means. /hi and it's actually hideout.zip because whenever you make a zip file, you want to end its name with .zip. Then, the last parameter is the file for zipping into the zip file.

So now we hit enter, and right there it says, "adding hi, stored at zero percent." Now here's hi.zip. Let me just throw it—hi is in the zip file right here, and I can double-click hideout.zip, and hi.zip extracts and then makes hi right there on my desktop. I can open it up, and there's hi indexed at it.

So now I'll throw out both of these when you have a zero, and on Apple, to throw it out, add zip. Then you have a zip file, and you double-click it to open it up. It will release everything that's inside of it onto the active directory.

So now let's do that a different way. We're gonna do a nano hi again, make just a random hi. Now hi's back on my desktop, and I'm gonna zip up hi. Actually, I'm gonna move hi to rename it from hi to hi1. Now hi is now hi1.

I can then take hi1 and zip it into the same hideout.zip. So already we can see hi is in hideout.zip, but now hi1 is gonna be added to it too because we're gonna do the same zip command, and hideout.zip already exists. That's okay, and we're going to zip up hi1.

Now we hit enter, and it's added hi1 to hideout.zip. We're gonna delete hi1 from my desktop. Open hi.zip, and now if you have more than one file in a zip file, it will create a directory with the zip file's name, except without the .zip.

So now here's hi; we open up hi, and here is hi and hi1. So now let's throw this out. Let's do one more thing: We're also going to zip up into hi.zip. We're gonna zip up documents into hideout.zip.

Now this is a little different because we're doing a directory. We do the same thing. We're gonna check documents here, so ./documents, but we're gonna have to do zip -r for recursively. And you know, arm -- sure means recursively remove this, move this recursively, whatever.

Our zip -r recursively, and it said all this stuff will come up. Whenever you zip any file into a zip file, it will take a while. So now it's taking a long time to zip up something because it's actually a large file.

So I'm just gonna do a cut here into the list. Unzip it. Okay, so we're done zipping everything into hi-dive.zip right here, and if we open it up, it will take a long time to extract, and it says "on archiving." This is gonna take a little while, but it's worth your wait.

Now all the documents inside of it and the directory inside of it will appear on my desktop.

So now it's done loading. Here's hi, and there's documents—everything in hi, and in highlights. If I'm gonna throw out hi, actually, I'm just gonna do an rm hi—save space, and I'm gonna have to do an rm -r hi.

Then I'm gonna do an rm hi.zip, so now my desktop is clean once again. So let's just make a new zip file just of documents, and I'm gonna show you one little thing. So I'm going to do another cut here as it zips up documents.

Okay, so now we have hi.zip. Let's just demonstrate one more thing with hi.zip. Zip plenty of stuff into it. It's actually just got documents in it at this point.

So now what I'm gonna show you is how to use the unzip command. Now look at this. We type unzip, and this is actually going to be a special experience. This means hi.zip.

What this does is the equivalent of double-clicking it to unzip, except if documents already exist on my desktop, it's gonna try to put documents on my desktop again. That's not gonna work out. Normally, when you do it with the GUI, documents one will appear on my desktop because there's already documents, but on this, it's gonna ask us what we want to do.

So let's do this. Now it says, "replace + y for yes to replace my Documents folder." No, we don't want to replace it. For no, that would just cancel the unzip because there's no other file, or you know, replace all.

And our four rename—let me type the letter we want and hit enter. So I'm gonna rename documents, which is trying to unzip to documents one right here, which is document small. Now this wants us to unzip everything in documents, and so we can either rename everything or do whatever we want.

So right now, I'm going to type our four rename documents. So now this is creating all the documents I want on my desktop. I'm just gonna cancel it at this point by pressing Ctrl+C.

Now say I dragged hideout.zip into another folder like programs. Just drag hideout.zip into here, and I unzip it here, whatever I want to do with cd programs. It will just unzip it normally.

Now we type unzip hidoc.zip and hit enter. Looks like I typed unzip wrong, and now it's gonna do all this crap for inflating, etc.

We can come over here to this find your window—see documents has appeared here. Everything in documents right now is being created, so more and more stuff is gonna come up here. Close this, and that's pretty cool!

And it's unzipping—it's done unzipping. Now let's just leave these documents on my desktop, go into programs, get rid of documents.

So that's how to zip a file folder, how to unzip something using the unzip program. And thanks for watching terminal lesson 5. Subscribe to Mac Heads at youtube.com / Mac Heads 101. We appreciate your watching, and goodbye.

More Articles

View All
Brainstorming: Is Your Mind Wild Enough to Make a Conceptual Leap? | Bill Burnett | Big Think
Everybody kind of knows the rules of brainstorming. You get four or five people together. By the way, you can’t brainstorm with 20 people. Everybody has to be able to see each other. I think of brainstorming like a jazz ensemble. Maybe you can have a trio…
Comedians, canaries and coalmines
Are you shocked at the amount of people that live in Western societies? Here in Norway, especially when we were in Sweden a couple days ago. But all the countries that we’ve been in that live in free societies yet are completely afraid to say what they th…
The 5 Best Investments For LIFE!
Hey guys, and welcome back to the channel! So today, I wanted to share my opinion on what I believe to be the five best investments you can make in your whole life. Now, some of you may have already noticed this, and yes, I do want to give a huge shout ou…
the earth is running out of time..
New York City, one of the United States’ most recognizable cities. In September 2020, one of the many artistic landmarks of the city was repurposed. It was the metronome near Union Square. If you’ve ever walked by it or seen it online, you’ll probably not…
How to have better sex | Esther Perel, Emily Nagoski & more
How is it that three, four decades after the sexual revolution we’re having less sex than ever? The reason people struggle so much with desire is because we have been lied to, fundamentally, about what desire is, and how it works. It’s not about statist…
Homeroom with Sal & Vas Narasimhan - Tuesday, August 17
Hi everyone, Sal Khan here. Welcome to Homeroom with Sal. We have a very exciting show today. After a bit of a hiatus, we haven’t done a live stream in a little while, but we have Vas Narasimhan, who is the CEO of Novartis. We had him on last year at the …