Dir
dir_compare¶
Compare two directories.
By default performs a quiet shallow comparison: checks whether the immediate children of both directories are identical (by name only, not content). Returns 0 if identical, 1 if they differ.
Flags: -r | --recursive Recurse into subdirectories (uses diff -rq) -v | --verbose Print what differs instead of remaining silent
Combining -r and -v runs diff -rq and prints its output. Combining -v alone prints added/removed names for shallow comparison.
Example¶
dir_compare /etc/skel /home/user # quiet shallow
dir_compare -r /etc/skel /home/user # quiet recursive
dir_compare -v /etc/skel /home/user # verbose shallow
dir_compare -r -v /etc/skel /home/user # verbose recursive
Arguments¶
- $1 (string): Path to first directory
- $2 (string): Path to second directory
Exit codes¶
- 0: Directories are identical under the chosen mode
- 1: Directories differ, or arguments are invalid
Output on stdout¶
- Nothing (quiet mode) or list of differences (verbose mode)
Output on stderr¶
- Validation errors