Two different folders, have the same name but they have different filesize. Is there any linux command that can compare two folders and tell me the diff in filesize at the same time?
vim, you could do:
vim -d =(cd dir1 && du -a | sort -k2) =(cd dir2 && du -a | sort -k2)
(you can replace
vim -d with
diff -u or
kompare or your preferred text comparison utility).
=(...) form of command substitution is the same as the
<(...) one found in ksh, zsh and bash with the exception that it uses a temporary file instead of a pipe so that it can work with commands that expect a regular file (like
vim). For commands that don't have that limitation (like
diff), you can use
The directory is just a mapping between file names and inodes, there are no "files in the directory". You can ask for the size of the files reachable through the directory by the command
du(1)). If you are worried about the size of the directory itself (as reported by
ls -ld directory), that includes current file names, space that was used by now erased files, padding, and assorted bureaucracy.
If you want to know if the files reachable have the same names/contents,
cmp(1) compares two files. Or
diff(1) (with the
-r flag) compares directories recursively (it is geared at text, though).