2
How do I sort
contents of two different folders before comparing those two directories using diff
?
2
How do I sort
contents of two different folders before comparing those two directories using diff
?
1
You could use diff
with process substitution:
diff <(ls -a dir1/) <(ls -a dir2/)
<(...)
creates a file descriptor whose path is added as argument to diff
.ls
sort the output alphabetically.ls
-outputs are give to diff
for comparsion.My example folders look like this:
.
├── dir1
│ ├── file1
│ ├── file2
│ └── file3
└── dir2
├── file2
├── file3
└── file4
The output is this case is:
$ diff <(ls -a dir1/) <(ls -a dir2/)
3d2
< file1
5a5
> file4
possible duplicate of compare two directory trees
– Paul – 2014-11-05T04:41:59.540can't use
rsync
. says not found – postit98 – 2014-11-05T05:22:11.183can I use
comm
in this? – postit98 – 2014-11-05T05:40:28.150