Live data from Hacker News

Unix tricks

mmb.pcb.ub.es

211–220 of 232 posts

Re: Unix tricks

#211
post #7
post #3

> SMB is better than NFS. More details would be nice.

NFS basically breaks the client computer until the host responds, while SMB detects the I/O error earlier and, at least, doesn't hang the terminal. Other than that, SMB allows for permissions and a bunch of other features. It is, basically, a more modern and robust protocol. Does NFS shine for some use cases? Indeed. Would it be the first choice for most ones? Nope. Disclaimer: my sysadmin skills are not so great, I'…

i cannot possibly disagree more. Are you using NFS from 1999?

Re: Unix tricks

#212
post #80
post #39

Earlier quoted context omitted.

An arguably better (and slightly more portable) way to accomplish this is the special variable $_ , which expands to the last argument of the previous command. Since $_ is a variable rather than a history substitution, it still works when there is no command history (e.g. in scripts) and allows all the usual variable expansion forms, for example ${_##*/} to extract the last path component.

That's good to know, although !$ is easier to type since you only need to depress the right shift key, whereas yours requires a quick shift on the opposite side. Makes a big difference when you're trying to quickly type "rm -rf !$" as root. :)

As a righty, I rarely ever use the right shift key.

Also, check it:

$ cd /happily/tabbing/out/some/really/deep/path/ooh/dear/maybe/its/java/WAIT_A.file

bash:> 'WAIT-A.file' is not a directory

$ nano $_ (opens file)

Re: Unix tricks

#213

Instead of ProxyCommand ssh -T host1 'nc %h %p' you can use ProxyCommand ssh -W %h:%p host1 which uses ssh itself and therefor also works on machines where netcat isn't installed.

Hi, I tried that but my ssh version doesn't have the -W flag. What would you suggest?

Unfortunately OSX uses a badly outdated openssh version just like many other unix tools and it doesn't support the -W option. You could try upgrading openssh using homebrew if you want.

Re: Unix tricks

#214
post #213

Earlier quoted context omitted.

Hi, I tried that but my ssh version doesn't have the -W flag. What would you suggest?

Unfortunately OSX uses a badly outdated openssh version just like many other unix tools and it doesn't support the -W option. You could try upgrading openssh using homebrew if you want.

I'm using Ubuntu 10.04 and it doesn't have the -W flag either.

Re: Unix tricks

#216
post #80

Earlier quoted context omitted.

That's good to know, although !$ is easier to type since you only need to depress the right shift key, whereas yours requires a quick shift on the opposite side. Makes a big difference when you're trying to quickly type "rm -rf !$" as root. :)

I don't think I'd type `rm -rf [ anything ]` quickly as root

Hence the smiley. Was a joke.

Re: Unix tricks

#217

Earlier quoted context omitted.

Try this in your .inputrc: # Bind the up arrow to history search, instead of history step "\e[A": history-search-backward "\e[B": history-search-forward No more "^rls" to search for ls in your bash history; just type "ls" and start hitting the up arrow.

Thanks for the suggestion. I used to have a very customized .bashrc with nice little things like that, but have decided to stick with standard stuff for things that work off of muscle memory. I got tired of sshing into a new box and half the things I'd type wouldn't work properly until I remembered to copy my settings files over, which seemed more trouble than it was worth for a short-lived s3 instance. That's why I…

> I got tired of sshing into a new box ...

I've got a public repo of my dotfiles, so the first thing I typically do is "git clone git@github.com:pavellishin/dotfiles.git && cd dotfiles && ./install.sh"

After that, I launch tmux, and it's all hunky dory.

Re: Unix tricks

#218
post #213

Earlier quoted context omitted.

Unfortunately OSX uses a badly outdated openssh version just like many other unix tools and it doesn't support the -W option. You could try upgrading openssh using homebrew if you want.

I'm using Ubuntu 10.04 and it doesn't have the -W flag either.

You need openssh 5.4+. I am running 12.10 and I've got 6.0p1

Re: Unix tricks

#219

"Add "set -o vi" in your ~/.bashrc to make use the vi keybindings instead of the Emacs ones." Better to do this kind of thing in .inputrc, as: set editing-mode vi (or set editing-mode emacs) because any application that uses readline gets to use those settings. So for example you get command line editing in various command line apps. bash uses readline, so you'll get that. The python repl will give command line editi…

s/wq/x/g
Post reply on HN