How to read a subfolder one by one in parent folder?

Hi friends,

               I am getting some trubles in folder reading. I am having 10 subfolders inside server7 folder. i wanna to read a subfolder name first and check if the foldername gets started with "http". if so , i need to read a file inside that folder. This willl continue for that 10 folders and quit after read the all subfolders. for the abov e requirement i wrote code like this 

for file in /x/y/server/* ;
do
start=`echo $file | cut -d "-" -f 1`
if [ $start == "http" ]
then
cd /x/y/server/$file/config
if [ -f filename ]
then
size=`ls -ltr filename awk '{print $5}' `
if [ $size == 0]
then
echo " The size of $filename is $size . "

here i gave only the fubctionality.

But i am to read very first folder only. I am not able to read rest of the folder.

can anyone help me for this...
Thanks in advance..

  1. Use 'find' utility (that seems to be the answer for your question)
  2. Imagine a file with name some tricky $name$ with
    newline characters
    and think how your code would work like... In fact how it would NOT work :smiley:
  3. Try using high level shell (you have not specified whether this is a HTML document or shell code or whatever) like ksh,bash,zsh,etc. Then provide "magic number" in the first line.
  4. If using a high level shell - use [[ ]] instead of [ ]
  5. I tend to use ksh with $() in place of `` - think about `ls `cat pattern_file`` (you can do $(ls $(cat pattern_file)) )
  6. If using ksh - try using print instead of echo
  7. Avoid nested code (someone told me that writing a lot of if's is not a bad thing... but some other man told me to avoid if's whenever possible - the second one gave me a good advice while the first one wasted my time)
  8. If you are using a high level shell then try using "${var}",'${var}' instead of what you wrote