Results 1 to 7 of 7
I am working on a shell script that will notify me when a specific file folder reaches a certain capacity.
In this case I would like to email myself when ...
- 01-24-2008 #1
reporting file/folder size for use in script
I am working on a shell script that will notify me when a specific file folder reaches a certain capacity.
In this case I would like to email myself when the folder reaches 4.5GB
i was hoping to use the du command, but how do use the output of the du command inside the script?
i.e. if i run the du command
that will reportCode:du /path/to/dir/
how can I get the du command to return just the size of the folder and not the rest of the information?Code:24431424 /path/to/dir/
thanks,
-C
- 01-24-2008 #2
Hi and Welcome !
You can use -m option with du for output in MB. Check manual of du.Code:du /path/to/dir | cut -f 1
man duIt is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 01-24-2008 #3
excellent .. the | cut -f 1 command was exactly what I was looking for.
- 01-25-2008 #4
new problem with du has arisen.
a user has thrown me for a loop and created a directory within the directory i am trying to monitor
i am using the following command
du -m /path/to/dir | cut -f 1
that returns the total amount of megabytes used by the folder.
however, if there is a folder within that folder .. it sends my two lines of data.
one for each directory involved.
what command can I run that returns just the amount of MB used by the folder in question .. regardless of it's contents??
i tried the -c command for a grand total .. but that outputs three lines of info.
thanks,
-chris
- 01-25-2008 #5
The "-s" flag is what you're looking for:
Code:-s, --summarize display only a total for each argumentDISTRO=Arch
Registered Linux User #388732
- 01-25-2008 #6
Have you tried looking at the du man page and reading what the "-s" option does? This might be exactly what you need.
--
Bill
Old age and treachery will overcome youth and skill.
- 01-27-2008 #7
ahh yes .. .the -s command.
I'm sorry for wasting time. I only is the -S in the man docs and missed the -s.
I guess that's what happens when you are debugging code at 4:00pm on a friday afternoon.
thanks though .. it's working perfectly now.
-chris


Reply With Quote