How to get into multiple directories in Linux
Hey everyone,
I have a directory list, say, test{0..9}. Now I'd like to get into each one and run some commands and then go to the next directory. Could anyone help me write a simple script to do that? Thanks in advance. Nan |
Hello xibeimunan,
Code:
for i in {1..9}; do cd test$i; yourcommandhere; cd ..; done |
Code:
for dir in test{0..9} ; do However this won't do if you need to set any variables that are to be read outside of the loop. So you could also do this: Code:
for dir in test{0..9} ; do |
Thanks a lot for your comments!
|
All times are GMT -5. The time now is 08:52 PM. |