I'm sure this can be optimised, but how's this for some dirty hackery.


server.dc home $  `cat _fdupes-2016-03-08.txt | xargs -n 3 | awk ' { print
 "rm -f " $2, $3  " ; ln " $1 , $2 " ; ln " $1, $3 } '`



Clue 1

the input file contains the output of fdupes, and listed only triples of
identical files.  There were no fours or twos
A better one would have looked for a blank line in the input, and looped
through from 2 to N .






Clue 2 before

server.dc home $ ll ./dir?/abc
-rw-rw-r-- 1 root nagios 76047612 Sep  9 22:39 ./dir1/abc
-rw-rw-r-- 1 root nagios 76047612 Sep  9 22:39 ./dir2/abc
-rw-r--r-- 1 root root   76047612 Oct 28 02:52 ./dir3/abc







Clue 3 after

server.dc home $ ll ./dir?/abc
-rw-rw-r-- 3 root nagios 76047612 Sep  9 22:39 ./dir1/abc
-rw-rw-r-- 3 root nagios 76047612 Sep  9 22:39 ./dir2/abc
-rw-rw-r-- 3 root nagios 76047612 Sep  9 22:39 ./dir3/abc



I think the nifty thing was -n 3 for xargs. I was unaware it could do that.


Answer
This machine has a lot of largish files triplicated on the disk.  Since I
can't convert it to a filesyystem with deduplication, this deleted 2/3 of
the files, and hard linked them back into place.
And the script merely spits out shell commands which are then executed. 
So testing it is just running the command without the backticks of
execution.

So the mount in question went from 355GB in use to 170GB, or 93% to 45%
usage.



-- 
Criggie

http://criggie.org.nz/

server.dc home $ `cat _fdupes-2016-03-08.txt | xargs -n 3 | awk ' { print "rm -f " $2, $3  " ; ln " $1 , $2 " ; ln " $1, $3 } '`



server.dc home $ ll
-rw-rw-r-- 1 root nagios 76047612 Sep  9 22:39 ./dir1/acd0c3db82df9164aed1dc395b482288
-rw-rw-r-- 1 root nagios 76047612 Sep  9 22:39 ./dir2/acd0c3db82df9164aed1dc395b482288
-rw-r--r-- 1 root root   76047612 Oct 28 02:52 ./dir3/acd0c3db82df9164aed1dc395b482288

server.dc home $ ll
-rw-rw-r-- 3 root nagios 76047612 Sep  9 22:39 ./dir1/acd0c3db82df9164aed1dc395b482288
-rw-rw-r-- 3 root nagios 76047612 Sep  9 22:39 ./dir2/acd0c3db82df9164aed1dc395b482288
-rw-rw-r-- 3 root nagios 76047612 Sep  9 22:39 ./dir3/acd0c3db82df9164aed1dc395b482288



This email, and any attachments, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. It is the property of Telogis, Inc. If you are not the intended recipient of this email, you are hereby notified that any dissemination, distribution or copying of this email, any attachments thereto, and use of the information contained, is strictly prohibited. If you have received this email in error, please notify the sender and permanently delete the original and any copy thereof.

_______________________________________________
Linux-users mailing list
[email protected]
http://lists.canterbury.ac.nz/mailman/listinfo/linux-users

Reply via email to