You are not logged in.
How can I extract a bunch of archieves?
gzip -dc *.tar.gz | tar x
That only extracts one. How can I do this recursively?
If I have the gift of prophecy and can fathom all mysteries and all knowledge, and if I have a faith that can move mountains, but have not love, I am nothing. 1 Corinthians 13:2
Offline
I don't think recursively is the word you want. That means you want to uncompress one and inside it there's another tar that you want to uncompress and inside that there's another one...
Luckily, that's the more difficult problem.
Try something like this:
for i in *.gz; do tar -xzf $i; done
I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal
Offline
Ah! That makes sense!
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.
Offline
You don't need so many do's
I think here the right script:
for i in *; do
cd $i;
./configure;
make;
make install;
cd ..;
done
Best wishes, Alexander Solovyov
Offline
I think this is better:
for i in *; do
if cd $i &> /dev/null; then
./configure && make && make install;
cd ..
fi
done
Offline
Thank you very much. 8)
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?"
Offline
instead of that if line, I think it's more understandable with something like this:
if [ -d $i ]; then
I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal
Offline
Heh. That makes more sense.
Offline
What's a good guide for bash scripting? I know the basics, but I want to know a little more. I'm coming from a C backgruond, what would you reccomend reading?
If I have the gift of prophecy and can fathom all mysteries and all knowledge, and if I have a faith that can move mountains, but have not love, I am nothing. 1 Corinthians 13:2
Offline
http://www.tldp.org/LDP/abs/html/
"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
Offline