LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   accessing variables inside a function (https://www.linuxquestions.org/questions/programming-9/accessing-variables-inside-a-function-306579/)

bahadur 03-27-2005 04:16 AM

accessing variables inside a function
 
#!/bin/bash

extractor()
{
FILES=`ls -l |awk '/^-/ {print $9}'`
SUBDIR=`ls -l |awk '/^d/ {print $9}'`
}

looper()
{
for FIL in $FILES
do
permissions.sh $FIL $3
done

for DIR in $SUBDIR
do
echo " the permissions being passed to other script are $2"
permissions.sh $DIR $2
search.sh $DIR $2
done
}



echo " Processing the directory $1"
cd "$1"

extractor
looper
--------------------------------------------------------------------------------------------------------------------

when i try to pass the $3 in the looper function it is not able to acces the variable $3 .

why cant that function access that variable?

acid_kewpie 03-27-2005 04:41 AM

afaik the $3 would be the third parameter passed to that specific function. why not save $3 as a sane variable when the script starts? $perms=$3 etc...


All times are GMT -5. The time now is 12:13 AM.