I'm trying to call a function from an if statement that is inside a for loop. I need to send the $i in "for i in *" to a function but i can find nothing that works.

ex.

# Perform actual file grab
for i in /Users/* ; 
   do
     if [[ -d $i && $(excludedDir $i) ]]; then
         echo $i;
     fi ;
done

Can anyone hep?

Your problem may be that the excludeDir is running in a subshell and not giving you the effect you want. Perhaps something like the following would work?

for i in /Users/*; do
    if [[ -d ${i} ]]; then
        excludeDir ${i}
        if [[ $? -eq 0 ]]; then
            echo ${i}
        fi
    fi
done
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.