Need help in finishing a bash script for listing subfolder by size in a large folder

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in finishing a bash script for listing subfolder by size in a large folder
# 1  
Old 12-04-2013
Need help in finishing a bash script for listing subfolder by size in a large folder

Greetings everyone.

I have seen that you do wonders here.

I have a large folder on a Ubuntu linux.

Organization main folder, inside 20 000 subfolders, and inside those subolders many other like 5-6 folders and files.

I am interested to create an output to a txt file under the bash shell, for the size only of those 20 000 subfolders, --maxdepth 1.

This is what I have tried so far, I was also trying to ommit with grep folders starting with a letter x, for testing. But whatever I do the command line hangs and produces no output.
du -h --max-depth=1 | sort -n

du /var -h --max-depth=1 | grep "^x.*" | sort -n

this produces nothing but this
ls -l | grep "^x.*"

gives some output on other server
du -h --max-depth=1 | grep x | sort -n | cut -f2 | xargs -d '\n' du -sh

Any help would be appreciated.

Thanks in advance.

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data

Last edited by Don Cragun; 12-04-2013 at 06:15 AM.. Reason: Add more CODE tags.
# 2  
Old 12-04-2013
directories are likely printed as ./dir
du -h --max-depth=1 | grep -v './x'

Last edited by Don Cragun; 12-04-2013 at 06:13 AM.. Reason: Fix CODE tags.
# 3  
Old 12-04-2013
what do you think about,
for USER in `ls /home`; do du -h --max-depth=1 /home/$USER/; done | awk '$1 > 100000000000 {print $1, $2}'

what does > 1000000000000 stand for ?

---------- Post updated at 11:27 AM ---------- Previous update was at 11:05 AM ----------

Ok, sorry for the mode , will use the code tag next time.

I understood the > 10000000 , it means that the first colon must be higher that 100000

Last edited by Don Cragun; 12-04-2013 at 06:11 AM.. Reason: Add CODE and ICODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash to copy subfolder and files to matching directory

The bash executes but returns no results and the set -xv showed while the $run variable in blue, was extracted correctly, the $match value in green, was not, rather both values in home/cmccabe/Desktop/f1 were extracted not just the matching. There will always be an exact match from the $run to... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

3. Shell Programming and Scripting

UNIX script to get folder size

can any one help me with a unix command to find out the size of each directory for files placed between 2 dates i.e., date1 & date 2? (3 Replies)
Discussion started by: Codesearcher
3 Replies

4. Shell Programming and Scripting

List of files in a folder inclusive subfolder

Hi, I need to list the names of existing files in a specific folder. I have written a script for that, but the problem is, it is also picking up name of a subfolder that is there in that folder. I need only the list of files and not that subfolder. How to go about that ? Can anyone plz help... (2 Replies)
Discussion started by: Subhasis
2 Replies

5. Shell Programming and Scripting

Bash script - $(ls expr) return double file name with one finishing with '.'

Hello. This small part of my script #!/bin/bash SRCDIR=/root/.kde4/share/config for MY_FILE in $(ls $SRCDIR/kate*) ; do echo "$MY_FILE" donegive : So for the moment I have modified my script like this : #!/bin/bash SRCDIR=/root/.kde4/share/config for MY_FILE in $(ls... (5 Replies)
Discussion started by: jcdole
5 Replies

6. Shell Programming and Scripting

Log folder size monitoring script

Hi All, Can anyone refer to me a readymade script for the purpose of log folder size monitoring script. Example : I have a log folder of size 10 G, and as the logs keep accumulating the folder gets full and i have to manually zip/remove the files in order to keep the server running. Something... (1 Reply)
Discussion started by: findjai
1 Replies

7. Shell Programming and Scripting

Create subfolder within folder in one command

suppose if i am checking folder g as shown below path a/b/c/d/e/f/g ,and some directory c,d,e,f,g not present then is there anyway to create directory in one command or i need to use mkdir for everyfolder (3 Replies)
Discussion started by: lalitpct
3 Replies

8. Shell Programming and Scripting

Link multiple files from different subfolder to a new subfolder

Hi, I have the following subfolder with files: /data/a/1/xxx.txt /data/b/2/yyy.txt /data/c/3/zzz.txt And i have a set of new folders which have exactly the same structure as above but different disk without the files: /data_02/a/1/ /data_02/b/2/ /data_02/c/3/ Now i would like to... (6 Replies)
Discussion started by: total_ysf
6 Replies

9. Shell Programming and Scripting

Command to view folder subfolder and its capacity

Can any one tell how to view folder and subfolder with its capacity df -k will cannot be used it shows only the parent folder while du -k will show all subfolder and files but not show the capacity and also i dont want view any files Thank you!!!! (1 Reply)
Discussion started by: shivu
1 Replies

10. Shell Programming and Scripting

How to read a subfolder one by one in parent folder?

Hi friends, I am getting some trubles in folder reading. I am having 10 subfolders inside server7 folder. i wanna to read a subfolder name first and check if the foldername gets started with "http". if so , i need to read a file inside that folder. This willl continue for... (1 Reply)
Discussion started by: kamatchirajan
1 Replies
Login or Register to Ask a Question