Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-14-2004, 08:50 PM
|
#1
|
|
Member
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944
Rep:
|
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
|
|
|
|
06-14-2004, 08:56 PM
|
#2
|
|
Senior Member
Registered: Aug 2003
Location: Honolulu, HI
Distribution: Arch
Posts: 1,380
Rep:
|
couldn't u just tar <filename> ~/.gkrellm2/themes/
|
|
|
|
06-14-2004, 09:13 PM
|
#3
|
|
Member
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944
Original Poster
Rep:
|
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?
|
|
|
|
06-14-2004, 09:15 PM
|
#4
|
|
Member
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 652
Rep:
|
tar xzvf *.tar.gz -C ~/.gkrellm2/themes
|
|
|
|
06-14-2004, 09:20 PM
|
#5
|
|
Senior Member
Registered: Aug 2003
Location: Honolulu, HI
Distribution: Arch
Posts: 1,380
Rep:
|
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
|
|
|
|
06-14-2004, 09:39 PM
|
#6
|
|
Member
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944
Original Poster
Rep:
|
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.
|
|
|
|
06-14-2004, 09:46 PM
|
#7
|
|
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113
Rep: 
|
How about
cd to ~/.gkrellm/themes
for f in /path/to/files/*; do tar xzvf $f; done
|
|
|
|
06-14-2004, 10:03 PM
|
#8
|
|
Member
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944
Original Poster
Rep:
|
Perfect! Thanks.
|
|
|
|
06-14-2004, 10:15 PM
|
#9
|
|
Member
Registered: Apr 2003
Location: Vancouver, BC
Distribution: Slackware, Ubuntu
Posts: 558
Rep:
|
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
|
|
|
|
06-14-2004, 11:12 PM
|
#10
|
|
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,560
Rep: 
|
Quote:
cd to ~/.gkrellm/themes
for f in /path/to/files/*; do tar xzvf $f; done
|
i would have thought that the above would cause the packages to be placed in ~/.gkrellm/themes/path/to/files/*
|
|
|
|
06-14-2004, 11:17 PM
|
#11
|
|
Member
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944
Original Poster
Rep:
|
It did what it was supposed to for me. I don't know enough about the for command to understand why though  .
|
|
|
|
06-14-2004, 11:49 PM
|
#12
|
|
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113
Rep: 
|
Quote:
Originally posted by Berhanie
i would have thought that the above would cause the packages to be placed in ~/.gkrellm/themes/path/to/files/*
|
Nah. It's saying 'for every tarball in that path, untar a tarball'. /path/to/files is the source and the current directory is the destination.
-- Glad it worked for you, jrdioko. 
Last edited by slakmagik; 06-14-2004 at 11:50 PM.
|
|
|
|
06-14-2004, 11:52 PM
|
#13
|
|
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,560
Rep: 
|
oh. i see. thank you. i misunderstood what was going on.
|
|
|
|
06-15-2004, 06:14 PM
|
#14
|
|
Member
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 652
Rep:
|
neat
**adds little command sequence to his list of neat linux things he did not know, and knows now**
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:00 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|