Live data from Hacker News

The Art of Command Line

github.com

51–60 of 134 posts

Re: The Art of Command Line

#52
If you're into the command line, I'd recommend getting a physical copy of Unix Power Tools [1] and spending some time with it. This is a nice article, but Unix Power Tools is better in almost every way for learning the basics (and more) of the Unix command line. This article mentions a few more modern tools, but Unix Power Tools has a far better explanation of what's going on.

[1] http://www.amazon.com/Unix-Power-Tools-Third-Edition/dp/0596...

Re: The Art of Command Line

#53
post #49

Earlier quoted context omitted.

I can't remember ever encountered a unix-like system without "vi" installed. I've used (and set up) machines running FreeBSD, DragonflyBSD, OSX, Ubuntu, Debian, RHEL, ... Plenty of those didn't have emacs, especially on first boot, when you're most likely to need to modify network configuration files in order to get online to install new packages in the first place... Edit: By "vi" I mean that somewhere in the path t…

> I can't remember ever encountered a unix-like system without "vi" installed. Default Ubuntu install.

Wow, seriously? I stand corrected -- still much more likely to find than emacs.

Re: The Art of Command Line

#54
post #33

So this is tangentially related by why do people seem to push Vi? Nano is a perfectly serviceable editor. If I need to do extensive editing I always end up loading it into Atom, Sublime or some other editor anyway. I've never really had to use a console editor for more than 10s of lines.

"I don't understand why everyone doesn't do things exactly like I do using only tools I like" is a really stupid way to look at the world.

Ironically, it's unclear whether you're countering the comment's argument, or the article's argument.

"Use vi, nothing beats it." == "I use x and I like it just fine."

If that was your intention, my mistake. It's just not apparent.

Re: The Art of Command Line

#55
post #40

cat hosts | xargs -I{} ssh root@{} hostname glad to know this one :-) echo y | xargs -Ix echo x how tricky!

I agree, this is one of my favorite tricks. I like to think of xargs as a `map` function over stdin lines.

As the article mentions, especially useful when combined with the -P flag for paralellism.

    cat urlpaths.txt | xargs -I{} -P wget domain.com/{}
Another handy trick, is to use `sh -c` or `bash -c` to include multiple commands with xargs.

    cat dirs.txt | xargs -I{} sh -c 'cd {}; touch file;'

Re: The Art of Command Line

#56
post #9
post #4

There's no reason to learn vi if you know Emacs. If you claim that Emacs isn't installed everywhere, guess what: Neither is vi. If you want an "installed everywhere" editor, learn ed. If you're willing to take an editor with you (or otherwise make sure a specific editor is everywhere you are), there's no reason it has to be vi.

vi is a posix requirement, emacs is not. If the system you're working on has ed, it'll have some version of vi or vim as well.

V7/x86 [1] has both vi and ed, but ed is easier to get to.

"Of course, we are not absolutely compelled to use ed, since V7/x86 comes with the full-screen editor vi (as well as the related line editor ex), but getting access to vi in this context would involve mounting the /usr filesystem and changing various environment variables and settings to allow editing in full-screen mode. Some basic ed skills are particularly useful in the V7 world, and most of all when one is involved on system administration tasks." [2]

[1] http://www.nordier.com/v7x86/

[2] http://www.nordier.com/v7x86/doc/v7x86intro.pdf

Re: The Art of Command Line

#57
post #49

Earlier quoted context omitted.

I can't remember ever encountered a unix-like system without "vi" installed. I've used (and set up) machines running FreeBSD, DragonflyBSD, OSX, Ubuntu, Debian, RHEL, ... Plenty of those didn't have emacs, especially on first boot, when you're most likely to need to modify network configuration files in order to get online to install new packages in the first place... Edit: By "vi" I mean that somewhere in the path t…

> I can't remember ever encountered a unix-like system without "vi" installed. Default Ubuntu install.

Ubuntu 14.04, the default Ubuntu on EC2, definitely comes with vi.

Re: The Art of Command Line

#58
> To locate a file by name in the current directory, find -iname something . (or similar). To find a file anywhere by name, use locate something (but bear in mind updatedb my not have indexed recently created files).

I think this will glob unless you escape the asterisks. Also on my system (debian 8) I need to put the directory to search first, or not at all:

find . -iname \something\

find -iname \something\

edit: hackernews ate all my asterisks

Re: The Art of Command Line

#59
post #15

If you learn bash, and you learn vi, then the next most glorious addition is: set -o vi Then you have vi keys in your shell. And it is marvelous.

That's nice, but it only affects the command line.

Instead of that, create the following file:

~/.inputrc (tilde slash dot-inputrc)

And in that file put at least this:

set editing-mode vi

Now every program that you run that a) has its own command line, and b) uses the readline library (there are a lot) has vi commandline editing. psql, mysql, telnet, lftp, and many more.

man bash has a section on READLINE. For example, in man bash search for

editing-mode

Re: The Art of Command Line

#60
post #24

> StrictHostKeyChecking=no And welcome to MITM haven. This is awful advice if you care about the first S in SSH.

What would be good is an interactive confirmation when a host fingerprint has changed, instead of a flatout abortion and having to edit your `known_host` file. I have to SSH into hundreds/thousands of VM that reuse the same IPs/FQDN sometimes, and the strict host checking is a major PITA. I haven't turned it off tho, I prefer the pain to MITM.
Post reply on HN