Showing posts with label BASH. Show all posts
Showing posts with label BASH. Show all posts

Wednesday, February 03, 2010

Process substitution

I suppose I should go buy a reference on BASH, but even the basic stuff never fails to amaze me. In doing more research on how to do a remote diff (see my last post), I found that another way to do similar thing using process substitution:

$ diff <(cat FILE1) <(ssh remote-host cat remote-path/FILE1)
$ diff FILE1 <(ssh remote-host cat remote-path/FILE1)

Monday, February 01, 2010

scpdiff

I often work on the same files across multiple computers (home, office, laptop) and I often wants to compare the work. This often involve copying a remote file locally, careful not to replace and existent file.

For convenience, I wrote the following function in my .bashrc:

Wednesday, September 09, 2009

Loop over filename with space

Instead of using
for x in $(find -depth 1 -type d); do
  ...
done
which breaks at space and therefore would fail for filename with space, do
find -depth 1 -type d | while read x; do
  ...
done