Diff
15 Dec 2022
`diff` Also Compares Directories
Short post so that I can remember this everytime I need to do something similar!
Using diff on more than individual files
#
The quick and dirty explaination is that the GNU/Linux diff command has an -r flag to recursively compare two folders. The command help indicates that it is shorthand for the full --recursive flag, which might be easier to remember.
diff --help
# ...
-r, --recursive recursively compare any subdirectories found
# ...
Example #
In the following example, “Only in” shows that particular files are only found in one of the folders. By default, matching files are not shown. If a file can be found in both folders and the two versions differ, the normal diff output is provided along with the modified times. All together these details provide a good summary of what a user might want to know when comparing two directories.
19 Aug 2021
Useful Docker Patterns (On GNU/Linux)
To easily copy files from a Docker image when you dont want to start a container, you can do the following:
docker cp $(docker create --rm $IMAGE):$FROM_PATH $TO_PATH
Sometimes it is useful to compare the output of a command between two Docker images, especially comparing different versions of a particular image:
docker run --rm -ti --entrypoint=bash $IMAGE1 -c "$CMD" > /tmp/output1.tmp
docker run --rm -ti --entrypoint=bash $IMAGE2 -c "$CMD" > /tmp/output2.tmp
diff -s /tmp/output1.tmp /tmp/output2.tmp
I have both these command patterns saved as executable Bash shell scripts on my system path as cp_docker and diff_docker_cmd respectively.