'cd' ing inside a shell script

dgmm freebsd01 at dgmm.net
Tue Nov 7 23:09:36 UTC 2006


On Tuesday 07 November 2006 14:37, Grant Peel wrote:
> Hi all,
>
> Some of my webmail users are using lots of disk space.
>
> I want to make a shell script, like so:
>
> cd /home/webmail/public_html/cgi-bin/etc/users ; du -h -d1 | grep M | sort
> -nr -k1
>
> and run it daily in a cronjob, mailing the results to my assistants.
>
> with the 'cd' at that start of the script have any adverse affect on the
> rest of the system or cronjobs? OK, will the scripot just complete and
> exit, with the 'cd' having no affect?

Do you need to be in the directory after the command has completed to then do 
something else.  If not, will this do the job for you?

du -h -d1 /home/webmail/public_html/cgi-bin/etc/users | grep M | sort -nr -k1

Dave
-- 
Dave


More information about the freebsd-questions mailing list