LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 06-14-2004, 08:50 PM   #1
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
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
 
Old 06-14-2004, 08:56 PM   #2
bosewicht
Senior Member
 
Registered: Aug 2003
Location: Houston, TX
Distribution: Arch
Posts: 1,381

Rep: Reputation: 47
couldn't u just tar <filename> ~/.gkrellm2/themes/
 
Old 06-14-2004, 09:13 PM   #3
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
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?
 
Old 06-14-2004, 09:15 PM   #4
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: a few...
Posts: 654

Rep: Reputation: 32
tar xzvf *.tar.gz -C ~/.gkrellm2/themes
 
Old 06-14-2004, 09:20 PM   #5
bosewicht
Senior Member
 
Registered: Aug 2003
Location: Houston, TX
Distribution: Arch
Posts: 1,381

Rep: Reputation: 47
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
 
Old 06-14-2004, 09:39 PM   #6
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
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.
 
Old 06-14-2004, 09:46 PM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
How about
cd to ~/.gkrellm/themes
for f in /path/to/files/*; do tar xzvf $f; done
 
Old 06-14-2004, 10:03 PM   #8
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
Perfect! Thanks.
 
Old 06-14-2004, 10:15 PM   #9
spurious
Member
 
Registered: Apr 2003
Location: Vancouver, BC
Distribution: Slackware, Ubuntu
Posts: 558

Rep: Reputation: 31
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
 
Old 06-14-2004, 11:12 PM   #10
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
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/*
 
Old 06-14-2004, 11:17 PM   #11
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
It did what it was supposed to for me. I don't know enough about the for command to understand why though .
 
Old 06-14-2004, 11:49 PM   #12
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
Old 06-14-2004, 11:52 PM   #13
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
oh. i see. thank you. i misunderstood what was going on.
 
Old 06-15-2004, 06:14 PM   #14
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: a few...
Posts: 654

Rep: Reputation: 32
neat

**adds little command sequence to his list of neat linux things he did not know, and knows now**
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to untar all tar-files in a directory? zoomzoom Linux - Newbie 13 05-09-2017 11:52 AM
cannot using FTP move command to move files adrianmak Linux - Networking 4 04-21-2009 12:01 PM
untar a list of tar files? Rotwang Linux - General 6 10-10-2006 01:34 PM
untar multiple files redhax8 Linux - Software 2 10-18-2004 01:13 AM
a way to untar multiple files alphisb0t Linux - Software 1 07-05-2004 12:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration