Originally Posted by Michael235
ls "$dir1" | wc -l > r
ls "$dir2" | wc -l > t
Use quotations, otherwise you are going to have a bad time if the directory has spaces in its name.
#let y=r+t I had error in this part I'm stuck here
Is there any reason why you use files to store the numbers? If there's one, then you will need to inline the cat's so they are expanded in the same formula, like this.
let y=$(cat r)+$(cat t)
But, what I'd do is to store the numbers in variables instead, so my version of the program would be more like this:
r=$(ls dir1 | wc -l)
t=$(ls dir2 | wc -l)