LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-18-2007, 11:34 PM   #1
creolophus
Member
 
Registered: Nov 2005
Posts: 34

Rep: Reputation: 15
ignoring directory structure with Tar


Hi,

I am writing a program which needs 'tar'

The problem is that 'tar' preserves directory structure, but I dont want it to.

I need to create a simple archive with all files inside it. No directory structure.

E.g
Code:
$ pwd
dir3
$ tar -cvf foo.tar  dir1/file1 dir2/file2
the file foo.tar is structured like this
Code:
--dir3--|--dir1 -- file1
        |
        |--dir2 -- file2
but I need
Code:
--dir3 --- file1 file2

Do you know the exact options? I've search the manual, without any luck

Thank you
 
Old 03-19-2007, 12:12 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
If what you want is not in the tar manual, then maybe tar won't do this...

You may need to have some lines in your script to move the files into one directory before tarring. In pseudo-code, I'm guessing something like this:
ls -R to list all files, regardless of subdirectory
loop thru all of these, deleting the directories, and using "mv" to put them in a new directory
 
Old 03-19-2007, 06:22 AM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Check out a program called "star". It is tar-compatible, but it has a zillion options. One of them is to create tar files without directory structure (-d).

Since the intention of this option to be compatible with "tar versions which do not deal with directories", your archive might contain a flat structure, but still be compatible with tar.

You'd have to check it out yourself.

jlinkels
 
  


Reply



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
taking tar back up of only the directory structure procfs Linux - Newbie 3 09-04-2006 07:54 PM
Directory Structure fedix Linux - Newbie 3 10-14-2005 02:48 PM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 06:05 AM
Can I tar a directory structure.... shelby Linux - General 9 02-20-2003 09:17 AM
GNU tar ignoring -X? akohlsmith Linux - General 0 07-12-2002 08:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:21 PM.

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