diff --git a/1998/schweikh3/.gitignore b/1998/schweikh3/.gitignore index 07db08510..f34630eca 100644 --- a/1998/schweikh3/.gitignore +++ b/1998/schweikh3/.gitignore @@ -4,4 +4,5 @@ file2 file3 file4 schweikh3.orig +samefile prog.orig diff --git a/1998/schweikh3/Makefile b/1998/schweikh3/Makefile index 253b4aa6a..6e3d6b077 100644 --- a/1998/schweikh3/Makefile +++ b/1998/schweikh3/Makefile @@ -131,6 +131,7 @@ all: data ${TARGET} ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + ${LN} -sf $@ samefile # alternative executable # diff --git a/1998/schweikh3/README.md b/1998/schweikh3/README.md index 47131411c..399c3d255 100644 --- a/1998/schweikh3/README.md +++ b/1998/schweikh3/README.md @@ -1,11 +1,8 @@ # Most Space Efficient -Jens Schweikhardt\ -DFN Network Operation Center\ -Schlartaeckerweg 3 (Home address)\ -D-71384 Weinstadt\ -Germany\ - +Jens Schweikhardt \ +\ +Germany ## To build: @@ -22,7 +19,7 @@ all your favorite pictures off the Internet or from `alt.binaries.pictures.*`, do ```sh -find dir -type f -print | ./schweikh3 +find dir -type f -print | ./samefile ``` Maybe you will not need to buy another 10 Gb disk to store them. :-) @@ -33,7 +30,7 @@ Maybe you will not need to buy another 10 Gb disk to store them. :-) If you're in this winning entry's directory: ```sh -find . -type f -print | ./schweikh3 +find . -type f -print | ./samefile ``` Notice that the tool finds a duplicate file, that of the man page. @@ -44,21 +41,17 @@ Notice that the tool finds a duplicate file, that of the man page. Try this: ```sh -cp schweikh3 file1 -cp schweikh3 file2 -cp schweikh3.c file3 -ln file3 file4 - -find . -type f -name 'file?' | ./schweikh3 +./try.sh ``` This program is not as smart as to detect identity of JPEG files with the same picture but with different compression levels. On the other hand compression can -make it thing look/sound/feel different so these probably aren't duplicates +make a thing look/sound/feel different so these probably aren't duplicates anyway. :-) -NOTE: Some non-gcc compilers that are not fully ANSI standard do not compile -this entry correctly. +Some time after this entry won, the Internet Systems Consortium (ISC) added the +samefile utility to its treasure of software gems! See the author's page about +the tool as well at . ## Author's remarks: @@ -66,11 +59,17 @@ this entry correctly. The source is expected to conform to IEEE Std 1003.1-1990 ("POSIX"). Thank God the IEEE does not standardize a coding style... + ### What this program does This is best explained in the man page. The troff source for this -man page can be found in the file samefile.1. To render try: `man -./samefile.1`. Otherwise: +man page can be found in the file samefile.1. To render try: + +```sh +`man ./samefile.1 +``` + +Otherwise: **SAMEFILE(1) User Manuals SAMEFILE(1)** @@ -80,21 +79,23 @@ man page can be found in the file samefile.1. To render try: `man **samefile** - find identical files + **SYNOPSIS** - **./samefile** + ./samefile + **DESCRIPTION** -**samefile** reads a list of file names (one file name per -line) from stdin. For each file name pair with identical +`samefile` reads a list of file names (one file name per +line) from `stdin`. For each file name pair with identical contents, a line consisting of six tab separated fields is output: The size in bytes, two file names, the character `=` if the two files are on the same device, `X` otherwise, and the link counts of the two files. The output is sorted in reverse order by size. -samefile uses two stages to give optimum performance. +`samefile` uses two stages to give optimum performance. In the first stage, all non-plain files are silently ignored (directories, devices, FIFOs, sockets, symbolic @@ -186,7 +187,7 @@ otherwise. `find(1)`, `ln(1)`, `rm(1)` -\ + ### Why I think it is obfuscated - The code is commented but this gives only an *extremely* faint clue. diff --git a/1998/schweikh3/try.sh b/1998/schweikh3/try.sh new file mode 100755 index 000000000..978dc6776 --- /dev/null +++ b/1998/schweikh3/try.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +make all || exit 1 + +echo "$ cp -f schweikh3 file1" +cp -f schweikh3 file1 +echo "$ cp -f schweikh3 file2" +cp -f schweikh3 file2 +echo "$ cp -f schweikh3.c file3" +cp -f schweikh3.c file3 +echo "$ ln -f file3 file4" +ln -f file3 file4 +echo "$ find . -type f -name 'file?' | ./samefile" +find . -type f -name 'file?' | ./samefile diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 2663b1885..fe76c1c96 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1669,6 +1669,19 @@ interesting historical explanation and further details and fun, see the README.md. +## [1998/schweikh3](1998/schweikh3/schweikh3.c) ([README.md](1998/schweikh3/README.md])) + +Cody added the [try.sh](1998/schweikh3/try.sh) script to make it easier to try +the commands that we suggested. One command was not added, that of the to use +command. + +Cody also made the Makefile rule `all` symlink the entry to `samefile` as that +is the name of the program. + +There actually is a web page for the tool and this was added to the author +information for the entry. It has not been added to any JSON file. + + ## [2000/anderson](2000/anderson/anderson.c) ([README.md](2000/anderson/README.md])) Cody changed this entry to use `fgets()` instead of `gets()` to make it safer