Live data from Hacker News

Know Your Tools – Terminal and Bash

spacecowboyrocketcompany.com

11–20 of 48 posts

Re: Know Your Tools – Terminal and Bash

#11
post #8
post #4

don't type `cd ~` just type `cd`

Also: Accidentally ran `cd`? Run `cd -` to return I think there are some pop/push mechanics for working directory too, but I can't find them right now.

Oh handy! Hadn't come across that before. Thanks.

Re: Know Your Tools – Terminal and Bash

#12
post #8
post #4

don't type `cd ~` just type `cd`

Also: Accidentally ran `cd`? Run `cd -` to return I think there are some pop/push mechanics for working directory too, but I can't find them right now.

The commands are pushd and popd, and they're bash (and zsh, and most sane shell) builtins. Pushd to get to a new directory, popd to go back to the last one on the stack.

Re: Know Your Tools – Terminal and Bash

#13

Very true. I have difficulties in training new recruits with UNIX. For some reason, beginners have developed an aversion to UNIX/shell scripting. I myself have started more and more of Ruby/AWK/Python, but it is always SHELL that blows me off with the sort of impact it has on the daily work. I ended up highly optimizing my work environment to replace long ssh connections with `conn prod` (will use my RSA key and conn…

I'm a relative newbie in the field, but I really love using terminal (I do all my C work for grad school in ViM), it's really essential at work, there's no faster way to do batch file processing a lot of times (especially with ffmpeg, awesome).

I'm surprised people don't like terminal, I love using it. It makes me feel old school, sort of like one of those hackers in the movies. That's probably just a personal thing.

I was familiar with most of the concepts but the links section made things click in that regard. Enjoyed the post as well.

Re: Know Your Tools – Terminal and Bash

#14
post #9

http://xkcd.com/1168/ ^_^

Lately, all of my tar use has been `tar -xvf filename`. I don't remember it always being the case that those options would automatically gunzip/uncompress, but they do now!

The best mnemonic I've encountered for remembering those flags is visualizing Arnold Schwarzenegger yelling them: "eXtract Ze File!!!"

Re: Know Your Tools – Terminal and Bash

#15
post #9

http://xkcd.com/1168/ ^_^

Lately, all of my tar use has been `tar -xvf filename`. I don't remember it always being the case that those options would automatically gunzip/uncompress, but they do now!

Hm, what OS? They didn't in the past. You needed to use 'tar -zxvf' for gunzip and 'tar -jxvf' for bzip2 IIRC. I still use it today to wrap files and move them on my server. On the server I use 'lzma' as default compression for archiving files (sql schemas, conf files, etc.)

Re: Know Your Tools – Terminal and Bash

#16
post #6

To exit vim use :wq, not just :wq - most of the problem is it getting stuck in insert mode, and not knowing how to escape into normal mode.

My first experience of vim was trying to fix my xorg.conf from a tty. I figured out how to save the file, but couldn't exit. In the end I hard-rebooted :$

Re: Know Your Tools – Terminal and Bash

#17
post #15
post #9

Earlier quoted context omitted.

Lately, all of my tar use has been `tar -xvf filename`. I don't remember it always being the case that those options would automatically gunzip/uncompress, but they do now!

Hm, what OS? They didn't in the past. You needed to use 'tar -zxvf' for gunzip and 'tar -jxvf' for bzip2 IIRC. I still use it today to wrap files and move them on my server. On the server I use 'lzma' as default compression for archiving files (sql schemas, conf files, etc.)

Primarily Ubuntu, I'm not sure if this worked on my laptop when I was using Arch a couple years ago... I'd estimate the behavior has been around since 2008-2009.

I've found the option[1], but it's not in my alias list.

Edit: Changelog says Version 1.20 (2008-04-14) introduced the --auto-compress option

[1]: http://www.gnu.org/software/tar/manual/html_node/gzip.html#a...

Re: Know Your Tools – Terminal and Bash

#18
Two very basic tips for vi:

You can use slash(/) and question mark(?) to search for text (forward and backward) in vi. It's useful to know these, because they also work with less(1).

If you are Windows user and used to press Ctrl+S to save the file and you accidentally do that in Vi, your terminal would get stuck. But you can use Ctrl+Q to unfreeze it.

Re: Know Your Tools – Terminal and Bash

#19

Very true. I have difficulties in training new recruits with UNIX. For some reason, beginners have developed an aversion to UNIX/shell scripting. I myself have started more and more of Ruby/AWK/Python, but it is always SHELL that blows me off with the sort of impact it has on the daily work. I ended up highly optimizing my work environment to replace long ssh connections with `conn prod` (will use my RSA key and conn…

When I was a student programmer, my boss came over to my desk to introduce my new project. He then fired up a terminal, ssh'd into the box where I would find the data. He then presented me the data by doing all kinds of bash magic. I was fairly impressed each time. I used some time just trying to make sense of what he did and how.

It's insanely useful.

Re: Know Your Tools – Terminal and Bash

#20
My most used bash command is probably "sudo !!", which runs the previous command with "sudo" prepended.

The book "Unix Power Tools" showed me that higher-level programming languages (Perl, Python, Ruby, etc) are not needed to accomplish most administrative tasks. Awk is incredibly useful (but also very confusing, imo).

Post reply on HN