works from cmd-line but not in script

hi
I'm trying to query a directory, check it's the right directory, return the results into a text file, put text file into an array and navigate the subdirectories and delete contents.

find `pwd` -type d | grep TESTINGDIR > dirList.txt

The txt file is created from the cmd-line but not in my script
Any ideas anyone?
Thanks

TESTINGDIR is a variable or constant in your case, as well as try to run the script without redirecting output to a txt file and see what you get on the screen, and also post here the error which you get at run-time.

Hi shereenmotor
thank you
without redirect to txt file i get the dir listing echoed back to me.

when I keep the redirect I get no error message at all and nothing is written to my dirList.txt file.
when I put
find `pwd` -type d | grep TESTINGDIR 2> dirList.txt

I get the dir listing redirected to stdout i.e. echoed back to me

With the above command, you are not redirecting standard output to dirlist.txt, its telling shell to redirect any errors(fd2) to dirlist.txt and standard output is redirected no where, therefor you are getting output echoed back at your screen, change your command as follows:

find `pwd` -type d | grep TESTINGDIR 1> dirList.txt

and see what you get.

Hi shereenmotor
thank you, this works from command line but does not from within the shell script.
I think i will just implement it differently
thank u for your time