You are not logged in.

#1 2010-03-27 16:22:15

zfsd
Member
Registered: 2010-01-13
Posts: 15

Making tarball while preserving fileorder

Greetings

I need to make a taball of a folder, of which the files are added in the alphabetical order.

The correct order:

$ ls -1 temp/
2010-03-09 01-33-13-40.log
2010-03-09 01-35-08-42.log
2010-03-09 01-37-12-26.log
2010-03-09 01-39-21-06.log
2010-03-09 01-41-28-12.log
2010-03-09 01-43-34-18.log
2010-03-09 01-45-41-00.log
2010-03-09 01-47-49-96.log
2010-03-09 01-50-03-17.log
2010-03-09 01-52-14-00.log
2010-03-09 01-54-31-17.log
2010-03-09 01-56-51-48.log
2010-03-09 01-58-50-15.log

However, when i try adding the files to a tarball, I get this:

$ tar -cvf tarball.tar temp/
temp/
temp/2010-03-09 01-45-41-00.log
temp/2010-03-09 01-54-31-17.log
temp/2010-03-09 01-37-12-26.log
temp/2010-03-09 01-52-14-00.log
temp/2010-03-09 01-43-34-18.log
temp/2010-03-09 01-33-13-40.log
temp/2010-03-09 01-41-28-12.log
temp/2010-03-09 01-50-03-17.log
temp/2010-03-09 01-47-49-96.log
temp/2010-03-09 01-39-21-06.log
temp/2010-03-09 01-35-08-42.log
temp/2010-03-09 01-56-51-48.log
temp/2010-03-09 01-58-50-15.log

Exactly the same order as if I did

$ find temp/
temp/
temp/2010-03-09 01-45-41-00.log
temp/2010-03-09 01-54-31-17.log
temp/2010-03-09 01-37-12-26.log
temp/2010-03-09 01-52-14-00.log
temp/2010-03-09 01-43-34-18.log
temp/2010-03-09 01-33-13-40.log
temp/2010-03-09 01-41-28-12.log
temp/2010-03-09 01-50-03-17.log
temp/2010-03-09 01-47-49-96.log
temp/2010-03-09 01-39-21-06.log
temp/2010-03-09 01-35-08-42.log
temp/2010-03-09 01-56-51-48.log
temp/2010-03-09 01-58-50-15.log

What attributes are the files sorted after, and how can I change this without having to make a script for it?

Thanks .)

Offline

#2 2010-04-01 04:51:25

Peanut
Member
From: Norway
Registered: 2009-05-24
Posts: 99

Re: Making tarball while preserving fileorder

Does this do the trick?

tar -cvf tarball.tar `find temp/*|sort -d`

Offline

Board footer

Powered by FluxBB