Simple Shell Script is b0rked!
Hey Users,
This simple shell scripts looks through all the sub folders in the given directory and in each sub folder is 2 text files, it counts how many lines are in each file and how many directories where accessed but it reports back all zeros (0)? Code:
#!/bin/sh Code:
[hades@hades ~]$ sh tester |
The pipe after the find command executes the loop into a subshell. After the subshell terminates all the variables local to the subshell itself are lost. You have to execute the while loop without calling a new subshell. One way is:
Code:
while read FOLDER |
Alternatively use a for loop
Code:
for file in `find /path/to/my/folder -maxdepth 1 -type d` |
Quote:
|
All times are GMT -5. The time now is 07:40 PM. |