#!/bin/bash # # copy-on-write wrapper for hard linked files # Copyright 2000 David A. Schleef # # 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