Bash problem

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: George Toft
Date:  
Subject: Bash problem
Kevin Brown wrote:
>
> > I have a large text file with a bunch of names in it.
> >
> > Is there an easy way to have a script grep each name out of the file and do
> > something with it?
> >
> > Like create a variable from each name with the name as the value?
> > Or check to make sure that name is a folder somewhere else?
>
> something like:
>
> for p in `cat file`
> do
> echo $p
> done
>
> (add dir checking in place of echo $p).
>
> for p in `cat file`
> do
> if [ ! -e "$p" ]
> then
>         `mkdir $p`
> else
>         if [ ! -d "$p" ]
>                 echo "Not a Directory, but file by $p name exists here"
>         fi
> fi

>
> Or something similar.
>
> ---------------------------------------------------



If the file is too big (>4K, I think), the for loop will bomb. Try
this:

while read LINE; do
    # Do something with LINE
done < file



George