recursive searching files in directory matching given name - taking care of links
Hi,
I am writing a shell script that finds all files named <myFile> in a directory <dir> or any of its subdirectories, recursively. I also need to take care of symbolic links that may form cycles, to avoid infinite loops. I am not supposed to use find command for the same I started writing the code but got stuck. I thought using recursion may be a smart way, but its not working. Kindly help Code:
#!/bin/sh |
have you looked at grep with -R option
Code:
grep -r <word> dir/* |
Also with your coding, unless a requirement of the class you are taking, why is FILE treated as a global
variable but DIR is then used as an argument? |
Quote:
Also you have a mis-typed variable name. Useful to use set -o nounset to make bash tell you about unset variables (including mis-typed names). |
@catkin - I guess I was being too subtle ;)
|
I was playing with this yesterday, declared the function variables as local, but still couldn't get it to go down more than two directories. The directory test line just fails the test.
Code:
+--test <--start here |
All times are GMT -5. The time now is 04:51 PM. |