Quote:
Originally Posted by camry
But It doesn't work
|
That's an incredible amount of info you give there
Which is what doesn't work? How do you use it? What results do you get? What did you expect it to do? Any error message? Please, info. Otherwise we can only guess which is what "doesn't work".
Just a note, when dealing with dir and file names use quotations around them. Otherwise if a name has spaces you are screwed.
Another note, I usually disregard the usage of the "ls" command for this purpose. It creates more trouble than it's worth. If you want to do so, use find with -exec instead.
Code:
find servers -exec tar -czf '{}'.tar.gz '{}' \;
If you are in bash you can just do this:
Code:
for i in servers/*
do tar -czf "$i".tar.gz "$i"
done
Curly brackets, as someone suggested, won't harm. But they are not needed in this case since the dot is not a character that can be used in an identifier (variable name in this case).