lkml.org 
[lkml]   [2001]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [OFFTOPIC] Hardlink utility - reclaim drive space
On Mon, Mar 05, 2001 at 07:17:18PM +0000, Padraig Brady wrote:
> Hmm.. useful until you actually want to modify a linked file,
> but then your modifying the file in all "merged" trees.

Use emacs, because you can configure it to do something
appropriate with linked files. But for those of us addicted
to vi, the attached wrapper script is pretty cool, too.





dave...

#!/bin/bash
#
# copy-on-write wrapper for hard linked files
# Copyright 2000 David A. Schleef <ds@schleef.org>
#
# Please send me any improvments you make to this script. I just
# wrote it as a quick and dirty hack.


linkedfiles=

for each in $*
do
case $each in
-*)
# ignore
;;
*)
if [ -f "$each" ];then
nlinks=$(stat $each|grep Links|sed 's/.*Links: \(.*\)\{1\}/\1/')
if [ $nlinks -gt 1 ];then
#echo unlinking $each
linkedfiles="$linkedfiles $each"
mv $each $each.orig
cp $each.orig $each
fi
fi
;;
esac
done

/usr/bin/vim $*

for each in $linkedfiles
do
if cmp $each $each.orig &>/dev/null
then
#echo relinking $each
rm $each
mv $each.orig $each
fi
done

\
 
 \ /
  Last update: 2005-03-22 13:22    [W:0.085 / U:5.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site