"if [ -d $i ];" works, but my way is shorter . The &> /dev/null redirects both stdout and stderr, cd prints an error message when it fails, so to get rid of it I used &>, could as well use 2>. I think it's natural to try to cd into a dir, and if that succeeds then do the make stuff. With [ -d $i ] you get problems when you don't have permission to go into the dir (perhaps the correct way is to use pushd and popd and/or make's recursive feature, but don't know about configure then).
A variant:
for i in *; do
if [ -d $i ]; then
cd $i && ./configure && make && make install && cd ..
fi
done
if [ -d $i ]; then
]]>I know this will work (though I haven't tried it on that group of files -- just some experimentation with it)
For the line "if cd $i &> /dev/null," I don't exactly understand how it works.
I understand that all output will be piped to /dev/null, but what is the & for? Is it not going to "spawn" a separate instance of each cd? Could you not just do "if cd $i > /dev/null?"
]]>for i in *; do
if cd $i &> /dev/null; then
./configure && make && make install;
cd ..
fi
done
I think here the right script:
for i in *; do
cd $i;
./configure;
make;
make install;
cd ..;
done
I was trying to compile Gnome 2.6 from source (when I was running Slack on my main box), and I tried to find that out.
The answer I got back used the find command with -exec. That worked well. Unfortunately I was stuck on how to not individually cd to each folder, do ./configure && make && make install, cd .., and then move to the next folder.
Would this work? (assuming that current folder only contains extracted folders)
for i in *; do cd $i; do ./configure; do make; do make install; do cd ..; done
(Do I need all those "do"s in there?)
This wouldn't jump into all subfolders, would it?
This is just a curiosity thing now, btw.
]]>Luckily, that's the more difficult problem.
Try something like this:
for i in *.gz; do tar -xzf $i; done
]]>gzip -dc *.tar.gz | tar x
That only extracts one. How can I do this recursively?
]]>