hardscrabble 🍫

By Max Jacobson

Psst. Check out my RubyConf 2017 talk, There are no rules in Ruby.

blog posts

Introducing myself to the command line

26 Feb 2012

I never really understood how to use the command line. I kind of got it in principle but not in practice.

So I taught myself the basics by reading this mini- book on Learn Code The Hard Way. It’s awesome. The book is an alpha release and may have some errors but I didn’t spot any. Would I, though?

Here are my thoughts and notes I jotted down while learning this. It’s fairly stream of conscious and certainly less accurate or helpful than the aforelinked mini-book. If you’d like to learn it along with me, maybe this could possibly be useful to you. It’s a little different on a Windows computer, but if you’re on a Mac or Linux computer, this should all work for you too.


I wonder how much stuff I’m gonna have to memorize.

I’m in the terminal! I’m in Terminal!

I’m learning bash. Apparently my nerd friends will tell me to learn zsh instead. I wonder if my actual nerd friends would.

Ok I think I get the whole cd and .. thing. If you’re in a directory you can cd into any subdirectory or cd .. to go back one. From the downloads directory I can cd ../documents to get to the documents folder. That goes up one and then back down into another.

I wonder if up and down are the right words to use there. In the Finder I think of it more as left and right, in the column view.

So far basically all I’m doing is making folders and moving through them. Loving it.

Whoa, I just deleted john! john was a directory I made. rmdir john is deadly.

At this point, the guide is saying if I want to I can take a break and come back tomorrow. It thinks I’m weak. I can do this.

I like that I can do mkdir -p i/like/icecream and it’ll make all three of those folders from scratch.

I wonder if I rmdir i, if it’ll remove all the subfolders too. Ohh cool, it won’t let me. That’s nice.

It’s kind of weird that when I rmdir something, it doesn’t go to the trash, it’s just gone.

pushd and popd are kind of baking my noodle (as Corey likes to say (note: this used to link to a podcast, but that podcast is gone). Is this like the popping and locking of the programming world? Maybe I should take a break.

OK so you’re in a directory. You pushd to/a/folder and now you’re there, but you sort of bookmarked where you were. If you want to go back there you popd. If you push somewhere, then push somewhere else, then pushd over and over you can cycle back and forth between them. If you popd over and over you can go back through the stack (from most recent to least recent I think?) of your pushds.

I love putting things in code brackets it’s really easy in Markdown/Calepin. I might be misusing it.

Ahh and the stack isn’t hidden! That’s what’s printed/returned when you pushd. I think I’m wrapping my head around this. Not sure if I’ve explained it well or anything, though.

I’m up to chapter nine. I just made an empty text file by writing touch iamcool.txt. Hey, your words.

I just wrote touch butts.mp3 and it made a song called Butts that I’m gonna be sending out to radio stations first thing tomorrow.

Ok so if I want to make a copy of iamcool.txt called awesome.txt it’s as easy as writing cp iamcool.txt awesome.txt! Okay! (In fact I am getting tired).

I’m slowly piecing together that -r does… well, something. I don’t know. If I mkdir afolder, I can then cp -r afolder ~/Desktop to make a copy of that folder on my desktop. But to copy awesome.txt to my desktop I just write cp awesome.txt ~/Desktop. So that -r I guess makes it work for a directory.

Hmm so now I’m moving files. But it sounds like renaming to me. mv awesome.txt lame.txt will basically rename it from awesome to lame. I suppose it’s moving the data from one file to a new one? Like, when you die your soul leaves your body and enters a baby just as it’s being born? If you believe in a very literal, specific form of reincarnation?

I know how to open a file in vim, and I even know how to do some basic vim commands, but I have no idea how to save a file and exit vim.

Ok I took a break. It’s two days later from when I started this. I’m happy that I still remember the commands I’ve learned this far.

I don’t know how to delete files but I can sort of do it by renaming one file into something else that exists, and it basically disappears I think.

I can also move a file from one folder into another folder with this. mv hello.txt afolder/hello.txt moves that file into the folder (though it doesn’t create the folder). So it’s moving and renaming.

Hmm.

Okay so now I’m using the less command to view the contents of text files. it seems to work just fine. I press q to exit. If it’s a long document I can page through it with w (up) or space (down), one page-worth at a time. Got it.

I can read markdown files in the terminal pretty nicely. I’m gonna navigated to my Calepin folder and open up this draft file. cd ../Dropbox/Apps/Calepin, ls, less cli.md wow there it is! Ha! This is fun.

I just whipped up a background image for my terminal. I wish it could tile and not just stretch. Looks good as long as I don’t resize the window.

Now I’m catting things. That just sort of displays the contents of the text file in a slightly different way than less. So exciting.

Oh thank goodness rm exists. I didn’t like that other way of deleting files.

OK so I can rm hello.txt to delete it but I can’t use rm to delete a folder (that’s what rmdir is for). Oh wait, I can, I just have to do some weird business. rm -rf folder works. Yoosh how do I remember that? Wait a moment. rm -rf can delete folder even if they have stuff in them. That one ups rmdir. This is “recursive deleting”.

I like this possibly self-delusional quote from the mini-book:

Now we get to the cool part of the command line: redirection.

I kinda knew about the | but not the < or >.

Oh! This is fun.

I just had a breakthrough wherein I learned how to save and close from vim, so I’ve just been playing in that for a little while. It’s :wq! So simple!

Ok, wildcard matching… ya yah.

Ex, ls *.txt will list only the text files. that’s handy. This command surprised me: cat *.txt > bigfile.txt took all of the txt files and combined them into one new one, which it also created. Then rm *.txt removed all of the txt files. That’s vicious.

Ok so this is a fun thing. I just realized I can open tabs in the Terminal! So I’m gonna write this post in one tab and learn things in another. Whoa. Although the switch-tab shortcut is kind of unwieldy (command-shift-] or [). I can learn it.

So I can run a command like grep hello *.txt and it’ll find the string “hello” in all the txt files and then return a list of all of the lines from all of the txt files that have that string in them. Useful. And if I want, I can pipe that to less and it’ll be the same thing, but easier to flip through (with space and w).

I thought I was done when I reached the section on man, which looks up the manual for any given command, but there’s a whole nother section. Great. I can handle some more knowledge.

I’m up to chapter 21. Weeks have elapsed. I’m not sure exactly what I just did and I can only hope it wasn’t bad. one of the thrills of using the command line is that I can completely destroy my whole computer at any point by writing the wrong thing.

In this chapter I “looked at my environment” and then set a variable and then printed out the variable. But where is this variable? In my environment? I feel like I don’t want it to be there anymore but don’t know how to get it out. Environmentalism! (I actually echo‘d it, not print. For what it’s worth.)

Now it wants me to research online “how you change your PATH for your computer” and do it all in the terminal. I think I’m just gonna skip this one.

Ah! Chapter 22 to the rescue. unset will flush that variable. Cool. I’m so relieved. I wonder if I can unset something important. That would be very unpsetting.

“You have completed the crash course. At this point you should be a barely capable shell user.” – Nice. I feel that way. It feels pretty great.

The conclusion links to this official bash reference. Also this cheat sheet. Maybe I’ll tackle those next.

Mosh Pits

07 May 2011

“I think it’s something that’s hard to recognize if you don’t experience it yourself”

Mariel Loveland:

I stood on the outskirts of the crowd for the entire show knowing I wanted absolutely nothing to do [with] the mass of 15 to 20-year-old boys pushing each other around, but the minute the closing band struck its first chord, I was shoved right into the middle. I immediately tried to look for a way out but was completely surrounded, and no matter how much I pushed, I couldn’t move. I was getting punched, kicked, and pummeled until I eventually fell down, and all I could see was a wave of dust and sneakers kicking and stepping on me. I couldn’t get up, and I couldn’t breathe. I choked on dirt and started sobbing until one man, probably someone’s dad, heard me screaming for help. He reached underneath the crowd and threw me over his shoulder. As he was pulling me away, I heard one voice cut through the music: “That’s why you don’t bring your little girl to shows.” I was 15.

I liked this little essay about being a girl at punk shows. It got me thinking back on my first time in a mosh pit (of not too many). It was at my Temple, at the annual Gefiltefest. Some local punk band was playing and kids got rambunctious. I was just enjoying the music but I got shoved into the vortex. I was around fifteen too. It was kind of fun at first but then I fell down and my glasses fell off. One of those naïve “is this the end?” moments. Almost immediately someone pulled me up, shoved my glasses into my hands, and pushed me out of the circle. There definitely weren’t any girls in there.

Another time, in college, I went to Montreal with some friends to see the band Thrice. This was during their Alchemy Index tour, which is when I first started listening to them. My friend Sung loved them, I think because he was an asian guitarist and Thrice’s lead guitarist is asian, and he’s pretty great. Sung had a friend in college in Montreal whose place we could stay at, and so we left our bags there, went and bought some of those extra-large bottles of canadian beer, wandered around a little, and went to the show. Say Anything was opening for Thrice, and were playing when we got there. The venue was way bigger than I’d anticipated. Less the grubby little rooms I was used to, more of a huge, multi-layered club. You could work your way up close to the stage if you want, and mosh around, or get a drink and watch from the mezzanine. We went right to the floor and got separated right away.

Say Anything didn’t sound so great so I went for a walk, to the bathroom, then the bar. There were a lot of French seeming girls there, not so many up front on the floor. Maybe they didn’t feel safe there. I don’t know. I didn’t, really, but that was kind of the fun of it.

By the time Thrice came on, things were getting to be kind of a blur. I didn’t know where my friends were. The plan was to find them later. I was never a massive Thrice fan, but one thing I really like is how they’ve progressed from a hardcore band in their early outings to a slightly more experimental rock and roll group. So I was a little surprised by how heavy the show was once it started, and how immediately the mosh pit congealed and dwarfed Say Anything’s. I was drawn in, willingly. The energy is hard to resist. I didn’t brave the thrashy center but I got shoved around a little, and shoved people around a little. And then my shoe fell off and disappeared into the crashing waves of converse all stars.

So now I’m kind of drunk and in a faraway land, and I’m hopping on one foot and everyone is shoving everyone and really loud music is playing and I’m not sure where my friends are. The adrenaline I’d been looking for? Found it.

Suddenly I see my shoe. Someone’s holding it above their head like a trophy, less than ten feet away, but a shifting mass of dozens of sweaty canadians between us. I start forcing my way through, on one foot, and reaching out, but the guy tosses it across the floor, like one might with a beach ball at a concert your parents would take you to. The crowd tossed it a couple more times before I managed to intercept it and pull it back on, at which point I receded to the edges where all you’re doing is helping people not fall down and being the one who picks up other people’s glasses and enjoying the music and catching your breath.


While writing this I listened to Ms. Loveland’s band Candy Hearts’ album Ripped Up Jeans and Silly Dreams which you can download for free there. It’s kind of nice. Hits that sweet spot between plaintive got-no-friends-but-my-guitar and us-against-the-world propulsion when the drums kick in. Not sure if that means much of anything, but I’m no music critic.