1. I don't follow you when you say "joint expression." What exactly do you mean by that?
2. I also don't understand why your rm command uses two asterisks. In your original post, you say you want to "Delete everything in /home/$exp$num/$dir" but then you use "rm -r $exp$num*/$dir/*" to do the deletion. If that were to work as I think you expect, when num=1, your rm command would delete numbered directories 1, 10, 100, 1000, 11, 12, 13, 1a, 1b, 1c, 1A, 1B, 1C, etc. And of course, similar behavior when num=2 and so on. If you want num to go from 1 to 45, might I suggest:
Code:
for num in $( seq 1 45 )
Now, I don't know if this will fix your problem (see question #1), but it's good practice to
always wrap your variables with curly braces. If you form the habit, you'll never have to worry about special cases when you must use them. In my opinion, they also make the script easier to read. For instance:
Code:
#!/bin/sh
cd /home
for exp in "rt ic sp"
do
for num in $( seq 1 45 )
do
for dir in "profile work"
do
rm -r ${exp}${num}/${dir}/*
done
done
done
exit 0