| View previous topic :: View next topic |
| Author |
Message |
shanie Newbie

Joined: Jan 02, 2010 Posts: 5
|
Posted: Wed Jan 27, 2010 12:17 am Post subject: Shell script |
|
|
I am working on my first shell script and i need som help please
I have a folder that i am sharing between my linux server and my windows computer at home with samba.
I want that folder not to take up more than 120 gb of my disk space.
Can anyone help me on the way how do i accomplish this by a shell script.
This is my script so far
#!/bin/bash
echo "The disk space of the directory blabla"
du -h /home/shane/blabla*
What i realise when i excecutes the script is, that it shows me the file size name of every files in that directory.
Can someone tell me how do i just get the total disk space that is used, i don't want to see whats in the directory only
the disc space that is used so far..?
Thanks  |
|
| Back to top |
|
 |
ffreeloader Master

Joined: Aug 10, 2005 Posts: 572
|
Posted: Wed Jan 27, 2010 11:54 am Post subject: Re: Shell script |
|
|
| shanie wrote: | I am working on my first shell script and i need som help please
I have a folder that i am sharing between my linux server and my windows computer at home with samba.
I want that folder not to take up more than 120 gb of my disk space.
Can anyone help me on the way how do i accomplish this by a shell script.
This is my script so far
#!/bin/bash
echo "The disk space of the directory blabla"
du -h /home/shane/blabla*
What i realise when i excecutes the script is, that it shows me the file size name of every files in that directory.
Can someone tell me how do i just get the total disk space that is used, i don't want to see whats in the directory only
the disc space that is used so far..?
Thanks  |
The easiest way to do that is to pipe the output of du into tail. Like this: du -h /home/shane/blabla | tail -1
If you don't know what/where the pipe symbol is on the keyboard it's Shift \. To find out more about how to use tail read the man page for it. Learning to pipe output from one command into another is very useful. |
|
| Back to top |
|
 |
shanie Newbie

Joined: Jan 02, 2010 Posts: 5
|
Posted: Wed Jan 27, 2010 7:19 pm Post subject: |
|
|
Thanks alot  |
|
| Back to top |
|
 |
shanie Newbie

Joined: Jan 02, 2010 Posts: 5
|
Posted: Wed Jan 27, 2010 11:14 pm Post subject: |
|
|
I have a folder that i am sharing between my linux server and my windows computer at home with samba.
I want that folder not to take up more than 120 gb of my disk space.
How do i accomplish this, i have read a little about disk quotas, is there another way? |
|
| Back to top |
|
 |
jimmo Administrator

Joined: Jul 27, 2002 Posts: 273 Location: Untersiemau, Germany
|
Posted: Thu Jan 28, 2010 11:35 am Post subject: |
|
|
| If you wanted the system to manage the 120 GB limit you might want to look quotas. Simply type "man quota" and that should get you started. |
|
| Back to top |
|
 |
jimmo Administrator

Joined: Jul 27, 2002 Posts: 273 Location: Untersiemau, Germany
|
Posted: Thu Jan 28, 2010 11:39 am Post subject: Re: Shell script |
|
|
| shanie wrote: |
echo "The disk space of the directory blabla"
du -h /home/shane/blabla*
What i realise when i excecutes the script is, that it shows me the file size name of every files in that directory. |
Try:
du -sh _directory_name_
-s = sum
(ffreeloader's suggestion is still a great trick to know when you just need the last line of output.) |
|
| Back to top |
|
 |
ffreeloader Master

Joined: Aug 10, 2005 Posts: 572
|
Posted: Tue Feb 02, 2010 10:43 pm Post subject: Re: Shell script |
|
|
| jimmo wrote: | | shanie wrote: |
echo "The disk space of the directory blabla"
du -h /home/shane/blabla*
What i realise when i excecutes the script is, that it shows me the file size name of every files in that directory. |
Try:
du -sh _directory_name_
-s = sum
(ffreeloader's suggestion is still a great trick to know when you just need the last line of output.) |
The last line of the output of du is the sum of all files in the specified directory. |
|
| Back to top |
|
 |
jimmo Administrator

Joined: Jul 27, 2002 Posts: 273 Location: Untersiemau, Germany
|
Posted: Wed Feb 03, 2010 8:19 am Post subject: |
|
|
| That's one of the things that has enthralled me with UNIX and then later Linux. There are so many different ways to achieve the same goal. |
|
| Back to top |
|
 |
|