Re: Shell Script Pointers?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tue, 2009-05-19 at 22:06 -0400, Eric Sisolak wrote:
> Also you could try
> 
> for FOLDER in `find /usr/local/squidGuard/db -maxdepth 1 -type d`; do

This is a classic mistake. It has two problems:
1) The list of files created by the embedded find can exceed the maximum
command length.
2) Directories with spaces in their name will be split by the tokenizer,
resulting in $FOLDER containing invalid or dangerous paths.

> instead of
> find /usr/local/squidGuard/db -maxdepth 1 -type d | while read FOLDER; do

This is the correct way to combine a shell loop with a program that
creates a list of files.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux