Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Aug 2002 16:16:27 +0200
From:      rene@xs4all.nl
To:        questions@freebsd.org
Subject:   /bin/sh "for" giving filenames with space as multiple parts :-((
Message-ID:  <20020810141627.GE76272@xs4all.nl>

next in thread | raw e-mail | index | archive | help
I have the following script;

#!/bin/sh
base=/mnt/xxl/unsorted

#main
if [ "1" != "0" ]
then
        for x in $base/*; do
                if [ -d $x ]
                then
                        for y in $x/*; do
                                echo $y
                                if [ `ls $y | wc -w` == 0 ]
                                then
                                        echo empty $y
                                else
                                        echo some $y
                                fi
                        done
                fi
        done
fi

#echo $0 finished


But when I run this, the $y-for-loop returns directory names with spaces as
several different items. I do not understand why, and would like to.

Also, this is in general giving me headaches (IFs with mandatory spacing,
bahhh). Shall I switch to perl or php? 

Greets from the perpetual newbie ;-)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020810141627.GE76272>