What I'm trying to do is rather easy to explain, but I don't know if it's possible.
The main idea is that I have directories which I want to add to a TAR file, but for some of them I don't want to include the files in the directory. I just want to add the path to the TAR file as if the directory was empty. As an extra information I can say that the directories are added via an update (tar -uf).
I do not think you can do that - directories are files with data in them. If you were able to extract just a directory with no actual files it referenced, then it would cause integrity problems for the filesystem. You would probably have to run fsck to fix it.
Note: I have never done any of this, so I don't know for sure.
Can you workaround it? - copy your directory tree to temporary disk storage, delete all the files and directories under the directories you want "clear" and then tar the whole mess?
Can you workaround it? - copy your directory tree to temporary disk storage, delete all the files and directories under the directories you want "clear" and then tar the whole mess?
I also thought about that, but it's too risky if some other scripts are running (which are using the files in the future TAR) while I make the tar.
I do not think you can do that - directories are files with data in them.
They certainly are, but on the systems I've played with it the OS doesn't let you play with their contents by means beyond mkdir, opendir, and unlink. It's also entirely possible to tar an empty directory:
Extracting that would amount to a mkdir and a chmod(confirmed on my system with strace). You can even tell tar, GNU tar at least, to not recurse into directories with --no-recursion, which will cause it to ignore all files in all directories you give it.
But I don't think you can force tar to pretend one particular directory is empty while recursing into the others. You could run tar twice, the first time adding the directories twice, the second time with the --append and --no-recusion options to add the 'empty' directories you want.
Last edited by Corona688; 02-02-2009 at 09:00 PM..
Hello, this is my first thread here :)
So i have a text file that contains words in each line like
abcd
efgh
ijkl
mnop
and i have 4 txt files, i want to add each line to each file, like file 1 gets abcd at the end; file 2 gets efgh at the end ....
I tried with:
cat test | while read -r... (6 Replies)
Quick question,
is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?)
sample:
/opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz
will the tar file backup.tgz also include backup.tgz ?
i tried... (5 Replies)
Hi,
I have tar filw which has multiple directories which contain files.
When i extract using tar -xf the directory structure also get extracted.
I require only files and not directory structures as there will be overhead of moving the files again.
So i searched here and got a solution but... (4 Replies)
Hi all,
I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
can someone give me a script to tar files that is older than 5 days in a directory that is not something like this:
fileArray=($(find -mtime +5 asdfasdf))
tar -cvf asfadfasdfa ${fileArray}
as the Unix I'm using has some problem with ($( )), I need another way to tar files in the folder.... (1 Reply)
I want to backup all the directory tress, including hidden directories, without copying any files.
find . -type d gives the perfect list.
When I tried tar, it won't work for me because it tars all the files.
find . -type d | xargs tar -cvf a.tar
So i tried rsync.
On my own test box, the... (4 Replies)
Dear all
I want to create a tar file which contains all executable files in a specific directory
cd /appl/home/
file some_exe
some_exe: 64-bit XCOFF executable or object module not stripped
My current approach is to tar it one by one
tar -cvf test.tar exefile1
tar -uvf test.tar... (2 Replies)
Hi,
i have more than 300 tar files in directory and i want to zip all tar files to single file.
could anybody tell me the command since i know how to do zip for single tar file:
bash-3.00$gzip 2008_11_10.tar
bash-3.00$ pwd
/oracle1/archivebackup
in this directory i have lot files... (2 Replies)
I received a tar file of a directory with 50,000 files in it. Is it possible to extract the files in the tar file without first creating the directory?
ie. Doing tar -xvf filename.tar extracts as follows:
x directory/file1.txt
x directory/file2.txt
.
.
.
I would like to avoid... (4 Replies)