Live data from Hacker News

Awesome but commonly unknown Linux Commands

anchor.com.au

31–40 of 88 posts

Re: Awesome but commonly unknown Linux Commands

#31
iftraf sounds interesting. I was looking for just such a program the other day.

I was sitting there and noticed with my iStat monitor that I was uploading something at 250 KB/sec. I closed Chrome and eventually all running programs in the doc, yet it still continued.

I tried to find out WHAT was uploading that, but to no avail. Any suggestions for tools? I ended up trying iftop, lsof -i, and netstat to get a glimpse, but it stopped before I could get to the bottom of it.

Re: Awesome but commonly unknown Linux Commands

#33

Meh, I was hoping for at least semi obscure things like the 'moreutils' utils. Speaking of which, many people don't know about the 'moreutils' utils. Check them out ;)

I see sponge is somehow useless, how is `| sponge /etc/passwd` different from `> /etc/passwd`.

The redirect happens before the command is executed, so if you're trying to read from /etc/passwd, it's already been overwritten. Sponge will buffer the output and write the file after the first command has executed.

Re: Awesome but commonly unknown Linux Commands

#34
post #7

Earlier quoted context omitted.

It's really handy for scripts too. pushd/popd definitely live up to the word awesome. For interactive use zsh has an option called autopushd that automatically pushes directories you `cd` to. I never remember to use pushd so it's a nice convenience.

It's not just handy for scripts, I think it's imperative in scripts where you want to go in and out of a lot of directories. for i in foo bar baz; do cd $i; #... do something cd ..; done; if "bar" doesn't exist, your cd .. will throw you off your original directory, whereas for i in foo bar baz; do pushd $i; #... do something popd; done; you'll be guaranteed that after "popd" you're back in the right place to start a…

You really, really should use 'set -e' which will exit if there are any errors. Otherwise if 'bar' doesn't exist, you'll 'do something' in a wrong directory and frobnicate something you didn't want frobnicated.

Re: Awesome but commonly unknown Linux Commands

#35

Earlier quoted context omitted.

I see sponge is somehow useless, how is `| sponge /etc/passwd` different from `> /etc/passwd`.

The redirect happens before the command is executed, so if you're trying to read from /etc/passwd, it's already been overwritten. Sponge will buffer the output and write the file after the first command has executed.

Ah, excuse my ignorance.

Re: Awesome but commonly unknown Linux Commands

#36
post #18

qmv from renameutils will bring up $EDITOR with all files in the current directory in two columns. Edit some filenames and save. The files will be renamed accordingly.

'rename' uses arbitrary perl expressions, including regexes. from the manpage:

  rename 's/\.bak$//' *.bak
Post reply on HN