[ale] my 1st shell script - chk big files
Pete Hardie
pete.hardie at gmail.com
Sun Mar 20 11:32:13 EDT 2011
On Sun, Mar 20, 2011 at 11:04, Ron Frazier
<atllinuxenthinfo at c3energy.com> wrote:
> Hello all,
>
> I've written my first Linux shell script as follows and saved it on the
> Desktop under the name Check Big Files and given it execute permission.
> I double click on it, the system asks whether to display or run it, and
> I say run.
congratulations!
<sniff> they grow up so fast these days... :)
>
> echo "Files larger than 100 MB starting from /." > file_list.txt
> echo "Excluding /swapfile, /sys/devices, and /proc." >> file_list.txt
> echo -n "Computer name: " >> file_list.txt
> uname -n >> file_list.txt
> echo " " >> file_list.txt
> date >> file_list.txt
> echo " " >> file_list.txt
> find / -type f -size +100M | grep -v /swapfile | grep -v /sys/devices |
> grep -v /proc >> file_list.txt
> echo " " >> file_list.txt
> date >> file_list.txt
> gedit file_list.txt
>
> It works very nicely, and give's me an instant report on large files in
> my system. You guys can tell me if you think anything needs changing to
> improve it. Anyone is welcome to use the script for their own
> purposes. If you publish it somewhere, give me the credit. Here's what
> it does.
>
> 1) Delete file_list.txt if it exists.
> 2) Create file_list.txt and put some headers, the computer name, and the
> date in it.
> 3) Find all files > 100 MB in size starting from / and list them in the
> text file, while excluding /swapfile, /sys/devices, and /proc.
> 4) Append the date to the end of the file.
> 5) Display the text file.
One suggestion I would give is to make this 2 scripts - one that just
does the work, and a second that calls the first and redirects the
output, then runs gedit on the result file - that will save you all
the ">>" output redirects
>
> I have a question. How would I force it to execute immediately, rather
> than asking if I want to display it or run it?
One suggestion from a quick Google is to wrap all that in another
script that does this "gnome-terminal -e <name>) where <name> is the
script you've written
--
Pete Hardie
--------
Better Living Through Bitmaps
More information about the Ale
mailing list