Rev 43 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 43 | Rev 55 | ||
|---|---|---|---|
| Line 22... | Line 22... | ||
| 22 | Usage()  | 
            22 | Usage()  | 
          
| 23 | { | 
            23 | { | 
          
| 24 | mesg="$1"  | 
            24 | mesg="$1"  | 
          
| 25 | 25 | ||
| 26 | echo "Usage: $progname directory"  | 
            26 | echo "Usage: $progname directory"  | 
          
| 27 | echo $mesg  | 
            27 | echo "$mesg"  | 
          
| 28 | }  | 
            28 | }  | 
          
| 29 | 29 | ||
| 30 | #  | 
            30 | #  | 
          
| 31 | # we need local vars to keep the value when called recursively  | 
            31 | # we need local vars to keep the value when called recursively  | 
          
| 32 | #  | 
            32 | #  | 
          
| Line 41... | Line 41... | ||
| 41 | curdir2=$(pwd)  | 
            41 | curdir2=$(pwd)  | 
          
| 42 | files=$(ls -a)  | 
            42 | files=$(ls -a)  | 
          
| 43 | for file in $files  | 
            43 | for file in $files  | 
          
| 44 | do  | 
            44 | do  | 
          
| 45 | pfile=$curdir2/$file # file including path  | 
            45 | pfile=$curdir2/$file # file including path  | 
          
| 46 | if [ $file != ".." -a $file != "." ]  | 
            46 | if [ "$file" != ".." -a "$file" != "." ]  | 
          
| 47 | then  | 
            47 | then  | 
          
| 48 | if [ -d "$file" -a ! -L "$file" ]  | 
            48 | if [ -d "$file" -a ! -L "$file" ]  | 
          
| 49 | then  | 
            49 | then  | 
          
| 50 | echo $pfile  | 
            50 | echo "$pfile"  | 
          
| 51 | traverse "$file"  | 
            51 | traverse "$file"  | 
          
| 52 | else  | 
            52 | else  | 
          
| 53 | if [ -f $file -o -L $file ]  | 
            53 | if [ -f $file -o -L $file ]  | 
          
| 54 | then  | 
            54 | then  | 
          
| 55 | echo "$pfile"  | 
            55 | echo "$pfile"  | 
          
| Line 65... | Line 65... | ||
| 65 | 65 | ||
| 66 | start_traverse()  | 
            66 | start_traverse()  | 
          
| 67 | { | 
            67 | { | 
          
| 68 | directory=$1  | 
            68 | directory=$1  | 
          
| 69 | 69 | ||
| 70 | echo $directory  | 
            70 | echo "$directory"  | 
          
| 71 | traverse $directory  | 
            71 | traverse "$directory"  | 
          
| 72 | }  | 
            72 | }  | 
          
| 73 | 73 | ||
| 74 | # =============================================================================  | 
            74 | # =============================================================================  | 
          
| 75 | # MAIN  | 
            75 | # MAIN  | 
          
| 76 | # =============================================================================  | 
            76 | # =============================================================================  | 
          
| 77 | 77 | ||
| 78 | progname=$(basename $0)  | 
            78 | progname=$(basename "$0")  | 
          
| 79 | if [ $# -eq 1 ]  | 
            79 | if [ $# -eq 1 ]  | 
          
| 80 | then  | 
            80 | then  | 
          
| 81 | directory=$1  | 
            81 | directory=$1  | 
          
| 82 | if [ -d $directory ]  | 
            82 | if [ -d "$directory" ]  | 
          
| 83 | then  | 
            83 | then  | 
          
| 84 | start_traverse $directory  | 
            84 | start_traverse "$directory"  | 
          
| 85 | else  | 
            85 | else  | 
          
| 86 | Usage "ERROR: No a directory : $directory"  | 
            86 | Usage "ERROR: No a directory : $directory"  | 
          
| 87 | fi  | 
            87 | fi  | 
          
| 88 | else  | 
            88 | else  | 
          
| 89 | Usage "ERROR: 1 argument expected"  | 
            89 | Usage "ERROR: 1 argument expected"  |