Compare Directories Using Diff Inwards Linux

To compare ii files, nosotros purpose the diff command. How create nosotros compare ii directories? Specifically, nosotros desire to know what files/subdirectories are common, what are exclusively inwards i directory but non the other.

Unix old-timers may recollect the dircmp command. Alas, that ascendancy is non available inwards Linux. In Linux, nosotros purpose the same diff ascendancy to compare directories too equally files.

$ diff   peter  george Only inwards /home/peter: announce.doc diff /home/peter/.bashrc /home/george/.bashrc 76,83d72 < < # Customization past times Peter < export LESS=-m < export GREP_OPTIONS='--color=always' < shopt -s histappend < shopt -s cmdhist < export PROMPT_COMMAND="history -a;$PROMPT_COMMAND" < #echo keycode 58 = Escape |loadkeys - Only inwards /home/george: .mcoprc Only inwards /home/peter: .metacity Only inwards /home/george: .newsticker-images Only inwards /home/peter: .notifier.conf Only inwards /home/george: targets.txt Only inwards /home/peter: .xsession-errors 


Without whatever option, diffing ii directories volition nation you lot which files exclusively be inwards i directory in addition to non the other, in addition to which are mutual files. Files that are mutual inwards both directories (e.g., .bashrc inwards the higher upwardly listing) are diffed to run into if in addition to how the file contents differ.

If you lot are NOT interested inwards file differences, only add together the -q (or --brief) option.

diff -q  peter  george  |sort Files /home/peter/.bashrc in addition to /home/george/.bashrc differ Only inwards /home/george: .mcoprc Only inwards /home/george: .newsticker-images Only inwards /home/george: targets.txt Only inwards /home/peter: .metacity Only inwards /home/peter: .notifier.conf Only inwards /home/peter: .xsession-errors Only inwards /home/peter: announce.doc


diff orders its output alphabetically past times file/subdirectory name. I prefer to grouping them past times whether they are common, in addition to whether they exclusively exist
inwards the outset or minute directory. That is why I piped the output of diff through sort inwards the higher upwardly command.

Note that past times default diff does non hit into the subdirectories to compare the files in addition to subdirectories at that level. To modify its behaviour to recursively become downward subdirectories, add together -r.

diff -qr  peter  george  |sort

Berlangganan update artikel terbaru via email:

0 Response to "Compare Directories Using Diff Inwards Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel