"In-Place Editing" using shell redirections instead of sed

Oh, nice one from Stefan Monnier in

    (rm /etc/conf.file;
     while read line; do
         echo ${line/old_word/new_word}
     done >/etc/conf.file) </etc/conf.file

Just in case your sed is not capable of the -i option and you don't want to mess with temporary files.


Help, ssh is eating up all my standard input!

If you're running ssh inside a shell script that's reading from standard input (stdin), beware that the ssh execution will drain stdin unless you use the -n option.

For example, take this loop:

while read host; do
   ssh "$host" hostname
done < /path/to/list-of-hosts

This will only loop once even if the file has multiple lines, since ssh is reading stdin attached to the whole loop and forwards it to the stdin of the "hostname" command executed on the remote host (which happily discards it, not reading from stdin at all).


diff remote files interactively with vim and ssh

Oh, this comes in handy:

vimdiff /path/to/file scp://remotehost//path/to/file

Damn, how many features do I actually know of vim? (thanks, Mika for pointing this out, there's even a blog post about it)

Finden kaputter Symlinks

Symbolische Links sind sehr praktisch, leider bleiben jedoch nach laengerer Nutzung eines Systems der eine oder andere kaputte Symlink (im englischen auch "dangling" oder "broken" symlink) ueber.

Um diese zu finden, gibt es mehrere Methoden:

Subscribe to RSS - shell