#!/bin/csh -f #(ie run the cshell on this but don't read the .cshrc) if ($#argv == 0) then echo version = 1.08 of lk 2011 Sep 04 # 2011 Sep 04, 1.08 update documentation # 2011 Jul 05, 1.07 hard links # 2001 Nov 5, 1.06 object if file exists # 2000 Nov 30, 1.05 allow for spaces in manes (passed in quotes) # 2000 Oct 19, 1.04 protect if file is there # 1989 November 6, 1.00 origin echo 'usage: lk [from-name] [to-file] [-hard] ' echo 'link NAME to FILE' echo ' ' echo "Link the first argument to the name given" echo "in the second argument:" echo ' ' echo 'lk NAME (to) FILE' echo ' ' echo 'You can make links if the file has spaces by surrounding' echo 'the names with quotes:' echo ' ' echo 'lk "Multipart NAME" "multipart FILE"' echo ' ' echo 'If there is a third argument, "-hard", a hard link is made.' exit # Note: stat [file] indicates in the third column the number of hard # links to a file, including the file itself. That is, a plain file # has '1', a file with a hard link to it has '2' (and both are then # links to the same disk space). So it is 'safe' to remove files with # '2' because there is another copy elsewhere. # Thomas D. Schneider, Ph.D. # National Institutes of Health # National Cancer Institute # Gene Regulation and Chromosome Biology Laboratory # Molecular Information Theory Group # Frederick, Maryland 21702-1201 # schneidt@mail.nih.gov # toms@alum.mit.edu (permanent) # http://alum.mit.edu/www/toms (permanent) endif if ($#argv == 1) then echo 'Two arguments needed\!' endif if (-e "$1") then echo 'lk: refuse to link: '$1' exists\!' exit endif if (! -f "$2" && ! -d "$2") then echo "WARNING: file or directory "$2" DOES NOT EXIST (yet?)" exit endif if ($#argv == 3) then # make a hard link set softlink = '' else set softlink = '-s' endif ln $softlink "$2" "$1"