DIRHASH(1)

✨ DIRHASH(1) ✨

okay bestie, buckle up β€” this is dirhash, and it lives under User Commands in your manual, so you already know it's a little CLI icon. πŸ‘‘


🌸 NAME 🌸

dirhash β€” Python module and CLI for hashing of file system directories. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

here's the whole vibe, straight up:

usage: dirhash [-h] [-v] [-a] [-m  [...]] [-i  [...]] [--empty-dirs]
               [--no-linked-dirs] [--no-linked-files] [-p  [...]] [-c]
               [-s CHUNK_SIZE] [-j JOBS] [-l] directory

what does it do? it determines the hash for a directory. that's it. that's the whole thing. πŸŽ€


πŸ’– positional arguments:

  • directory β€” the directory you wanna hash. give it the path, it does the rest. no cap.

✨ optional arguments:

  • -h, --help β€” shows this help message and dips. classic. πŸ‘‹
  • -v, --version β€” shows the program's version number and exits. say hi to the number then bounce.
  • -a, --algorithm β€” which hashing algorithm you wanna use. default is "md5". the always-there squad is: ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']. and then, depending on your current platform, you also get: ['blake2b', 'blake2s', 'md4', 'md5-sha1', 'ripemd160', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'sha512_224', 'sha512_256', 'shake_128', 'shake_256', 'sm3', 'whirlpool']. heads up bestie: the same algorithm can show up multiple times in that set under different names (blame OpenSSL, not us) β€” see [https://docs.python.org/2/library/hashlib.html](https://docs.python.org/2/library/hashlib.html).

🧚 Filtering options:

here's where you pick and choose what files and directories make the cut. by default, everything is included β€” all files and directories, symbolic links included. the --match/--ignore args let you select using glob/wildcard (".gitignore style") path matching. the paths get matched relative to the root directory β€” meaning the name of the root directory itself is excluded from the matching. so the patterns you hand over are matched against those relative paths.

for example, if you ONLY want python source files, go:

dirhash path/to/dir -m "*.py"

or if you wanna exclude hidden files and directories:

dirhash path/to.dir -i ".*" ".*/"

which is just short for:

dirhash path/to.dir -m "*" "!.*" "!.*/"

and if you tack on the --list argument, instead of the hash value you get back all the included paths for whatever filtering args you gave. want even more details? go read [https://github.com/andhus/dirhash/README.md#filtering](https://github.com/andhus/dirhash/README.md#filtering). 🫢

  • -m, --match β€” one or several patterns for paths to include. ⚠️ NOTE: patterns with an asterisk MUST be in quotes ("*") or the asterisk has to be preceded by an escape character (\*). don't get caught slipping.
  • -i, --ignore β€” one or several patterns for paths to exclude. ⚠️ same NOTE: asterisk patterns need quotes ("*") or an escape character before the asterisk (\*).
  • --empty-dirs β€” include empty directories, i.e. ones containing no files that meet the matching criteria and no non-empty sub directories.
  • --no-linked-dirs β€” do not include symbolic links pointing to other directories.
  • --no-linked-files β€” do not include symbolic links to files.

πŸ’œ Protocol options:

these ones decide what properties of files and directories get baked into the hash, and whether cyclic links are allowed. more deets at [https://github.com/andhus/dirhash/DIRHASH_STANDARD.md#protocol](https://github.com/andhus/dirhash/DIRHASH_STANDARD.md#protocol). ✨

  • -p, --properties β€” list of file/directory properties to include in the hash. available properties are: ['name', 'data', 'is_link'], and at least one of name and data must be included. default is [data name], which means both the name/paths AND the content (actual data) of files and directories get included. the whole package, periodt.
  • -c, --allow-cyclic-links β€” allow presence of cyclic links (by hashing the relative path to the target directory). πŸ”„

πŸ‘‘ Implementation options:

  • -s CHUNK_SIZE, --chunk-size CHUNK_SIZE β€” the chunk size (in bytes) used when reading files.
  • -j JOBS, --jobs JOBS β€” number of jobs (parallel processes) to use. go fast, bestie. πŸ”₯

πŸ“ Special options:

  • -l, --list β€” list the file paths that will be taken into account, given the filtering options you provided.

🌈 SEE ALSO 🌈

the full documentation for dirhash is maintained as a Texinfo manual. if the info and dirhash programs are properly installed at your site, this command:

info dirhash

should give you access to the complete manual. iykyk. πŸ’«


and that's a wrap, bestie!! this whole thing is dirhash 0.2.1, dated December 2021 β€” iconic behavior, honestly. go hash a directory, you've got this. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from