LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-08-2014, 08:33 AM   #1
AntBla
LQ Newbie
 
Registered: Oct 2012
Posts: 16

Rep: Reputation: Disabled
Add up folder sizes in list contained in text file


Hi All.
I have a list of folder in a text file (these folders have sub folders too).
I want to be able to add up the folder sizes in human readable format.
Thanks in advance for any help.
V.
 
Old 08-08-2014, 08:38 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
what have you tried so far ? also please provide a sample before-and-after ?
 
Old 08-08-2014, 08:43 AM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Code:
du -s /path/to/folder
the trick is to use your list

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashGuide
http://www.gnu.org/software/bash/manual/bashref.html

The tldp stuff is great, however there are some nasty bad habits in it,
The mywiki.wooledge does a very good job of 'fixing' those habits


if you get stuck, show us what you have

hint:

'feed' a "while read" loop using "heredocs"
and do some sums..
 
Old 08-09-2014, 08:56 AM   #4
zer0python
Member
 
Registered: Sep 2003
Posts: 104

Rep: Reputation: 20
Woah, Firerat, that really brought me back to the days of "ask how to to do something simple" get a 1000 page book of technical docs thrown at ya face.
Anyway, Firerat pretty much gave you an answer.

But another potential way of doing things (just to get ya thinking):
http://www.cyberciti.biz/faq/linux-u...lists-utility/
 
Old 08-09-2014, 09:37 AM   #5
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Well, homework questions should involve homework
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sum numeric columns contained in a plain text file gacanepa Linux - Newbie 6 10-04-2013 10:19 PM
[SOLVED] how to list all ascii/text files in a folder recursively? suhasingale Linux - Newbie 3 11-18-2011 02:28 PM
How to list the directories of a file system by their sizes? joaotelles Solaris / OpenSolaris 3 12-04-2008 03:11 PM
what is the command to add text into a text file? newbiebash Programming 2 09-08-2008 09:07 AM
Utility Needed - list folder tree and files in text file Optiker Linux - Software 21 11-17-2006 03:46 PM


All times are GMT -5. The time now is 12:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration