Solved

compare two directories and list size of all sub directories in two columns in linux shell script

Posted on 2014-01-30
3
383 Views
Last Modified: 2014-01-31
Hi,
Would like compare two directories (recursively) and display only the size in GB from all sub directories in two columns in linux

subdirname      pdir1        pdir2
one                    1GB      1GB
two                    1GB      1.1GB
three                 1GB      1.2GB
four                  1.1GB      1GB

Thanks in advance
0
Comment
Question by:enthuguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 300 total points
ID: 39822755
(cd pdir1 ; du -h | awk '{print $2,$1}' | sort ) > d1
(cd pdir2 ; du -h | awk '{print $2,$1}' | sort ) > d2
join d1 d2
0
 
LVL 19

Expert Comment

by:simon3270
ID: 39824357
Small change - that would display the size of each file under the directory, and use whatever size was appropriate.  To force it to use GB, and do summary sizes of the subdirectories (or files) directly in  the two directories, the du command changes from "du -h" to:
    du --block-size=G -s *
0
 

Author Comment

by:enthuguy
ID: 39825491
Thanks very much ..that helped.

Tried this with slight change
(cd pdir1 ; du -sh * | awk '{print $2,$1}' | sort ) > d1
(cd pdir2 ; du -sh * | awk '{print $2,$1}' | sort ) > d2
join d1 d2
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question