Untar/move multiple files in one step
Here's a fun question. I downloaded a file that contains all the gkrellm skins and untarred it only to discover that it contains about 200 individual tar files. I want to, in the easiest way possible, run tar -xvzf filename on each one and then move the folder that gets created by the untarring process to ~/.gkrellm2/themes/. Do I need to do some shell script with variables and loops to accomplish this? I assume I can do this with just the tar and mv commands alone. Actually, once I get them all extracted, I think I can just mv *gz (since some are .tar.gz and some are .tgz) to another place and then mv * to the themes folder. I do need help on untarring all of them though.
Thanks in advance, Johnathan |
couldn't u just tar <filename> ~/.gkrellm2/themes/
|
I'm not sure exactly how that use of tar works. Will it put all the files in the tar in ~/.gkrellm2/themes, or will it create a folder ~/.gkrellm2/themes/filename/ and put all the files in there (that's what I need). Also, that takes care of one, but there are 200 individual tarballs that I need to do this with (hopefully not one at a time). Any suggestions?
|
tar xzvf *.tar.gz -C ~/.gkrellm2/themes
|
if the packager did it right, each tar should unpack to it's own dir. for tar, try tar --help or man tar. so using the command i posted before u could possibly try to cd to the dir that u have the tarred file and try:
tar -xvf * ~/.gkrellm2/themes/ this seems like it would extract everything in that dir that u are currently in and move them to ~/.gkrellm2/themes/ not too sure if this will work though, seems like it should |
That just spits back an error for every one. For example,
tar: sunset.gkrellm.tar.gz: Not found in archive and so on for every package. |
How about
cd to ~/.gkrellm/themes for f in /path/to/files/*; do tar xzvf $f; done |
Perfect! Thanks.
|
Just to be complete, you can also specify multiple files with {} eg.
If you have a directory full of files like DCN001.jpg, DCN002.jpg, etc. but just wanted to move DCN012.jpg, DCN023.jpg and DCN041.jpg, then do: mv DCN{012,023,041}.jpg /newdirectory |
Quote:
|
It did what it was supposed to for me. I don't know enough about the for command to understand why though :).
|
Quote:
-- Glad it worked for you, jrdioko. :) |
oh. i see. thank you. i misunderstood what was going on.
|
neat
**adds little command sequence to his list of neat linux things he did not know, and knows now** |
All times are GMT -5. The time now is 10:28 PM. |