Archiving and move files in the same time

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Archiving and move files in the same time
# 1  
Archiving and move files in the same time

Hi All,

I have tried so many command but none work like i wanted.

I would like archive which i assume it will move the files and archive it somewhere.

for example:

if i have a folder and files:

i would like to archive folder blah which including the subfolder.
i use gtar -czf backup.tar.gz blah

but it does not actually move the files "test" and "hello" and "bar"

Is there any way to archive specific files inside directory/subdirectory but actually also move the files to the archive file but i would like to keep the dir structure as well?

please help any advise..
# 2  
How about if you try

gtar -czf backup.tar.gz blah/*

Nb: But the files are not moved. The archive will have a copy of the files but they will still exist in /home/blah/...

Last edited by Vi-Curious; 08-18-2008 at 12:52 AM.. Reason: Add comment
# 3  
Hi Vi-Curious,

It does the same as
gtar -czf backup.tar.gz blah

it does not move the files in the source but making a copy instead.
# 4  
It is not going to move the files, ever. If you want the files moved, you need to move them. And where do you want them moved to or do you really just want them deleted? I don't think I understand what you want to happen.

As for my previous post, I guess I misunderstood you there as well. I thought you were saying that gtar did not put the files (located in the subdirectory) into the archive file. It should, without the /*, but I thought you were saying it didn't.
# 5  

What i'm trying to do is:
I have many files that our company don't use anymore but i need to keep it up to 10 yrs..
What i want is to archive all those files to a separate harddrive/partition.
if i use gtar -czf backup.tar.gz blah, it will give me a copy of those files to different location which i don't want that.
i would like to take all those files away from source to destination but specific files only..
# 6  
I still don't understand your resistance to using the gtar archive. If you have files in some source directory that you want archived and stored in some destination, you can gtar the files to be archived, put the gtar file in the destination, and delete the files from the source directory. By using gtar, you are compressing the archived files so that they don't take as much disk space.

If, however, you really don't want to bother with the compressed archive file, you can just use mv to move the files where you want them.

The main question, then, is how do you identify which files you need to archive? What is the criteria?
# 7  
Sorry if I'm stating the obvious here, but GNU tar has an option --remove-files to delete archived files.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #273
Difficulty: Easy
In December 1939, Turing solved the essential part of the naval indicator system, which was easier and less complex than the indicator systems used by the other services.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to move files older than certain time?

If there are 100 files created in a directory /data/ today from 2:00 AM to 10:00 AM I need to move files older than 3:00 AM to a new directory /hold/ How to do that? Also, if I have to move files between 3:00 AM to 9:00 AM, how to achieve that (3 Replies)
Discussion started by: eskay
3 Replies

2. Shell Programming and Scripting

Process 2 lists at the same time and move files.

I have this while loop, that works but is quite slow to process though. I'm hopping there might be a faster/better way to find what I'm looking for. I have 2 lists of numbers, and want to only find files where a file name has both values present. each list has about 100 values. while... (10 Replies)
Discussion started by: whegra
10 Replies

3. Shell Programming and Scripting

Archiving or removing few data from log file in real time

Hi, I have a log file that gets updated every second. Currently the size has grown to 20+ GB. I need to have a command/script, that will try to get the actual size of the file and will remove 50% of the data that are in the log file. I don't mind removing the data as the size has grown to huge... (8 Replies)
Discussion started by: Souvik Patra
8 Replies

4. Shell Programming and Scripting

Archiving the files

hi, Am trying to acrhive a bunch of files on some ftp site and somehow managed to come out with the below logic. I'm getting "syntax error: unexpected end of file" error. Interestingly this below snipeet works fine if run for the first time but the subsequent runs fail! Anybody has any idea... (3 Replies)
Discussion started by: Amee5
3 Replies

5. Shell Programming and Scripting

Help to reduce time of archiving

hi all, i have written the following script that does this work: 1. copy large logs files from one server to another. 2. then unzip this files and extraxt from these large https logs only those fields that are neccesary. 3. then archive the extracted logs to new files. BUT the problem is... (7 Replies)
Discussion started by: arrals_vl
7 Replies

6. UNIX for Dummies Questions & Answers

How to move files based on filetype and time created?

Hi, I'm trying to improve my Unix skills and I'm wondering what is the best way to move some files based on filetype and attributes like time created? For instance, lets suppose I have a directory with many different files in it and I'd like to move all the jpgs that were created between May... (6 Replies)
Discussion started by: LuckyTommy
6 Replies

7. UNIX for Dummies Questions & Answers

move files between file systems with privileges, time stamp

Hi I have to move files between file systems but files in new file system must have the same attributes as in old one (privileges, time stamp etc). Which tool is best : - ufsdump / ufsrestore - tar - cpio - pax - dd - mv Or maybe there is sth else, you suggest to use. Thx for help (5 Replies)
Discussion started by: presul
5 Replies

8. Shell Programming and Scripting

Move files one at the time and wait until the previous file is handled

I'm a novice at unix and need it more and more to do my work. I seem running into problems getting this script "attempt" to work: I need to copy all files in a directory, which is containing 22000 files, into a directory one level up. There a tool monitors the content of the dir and processes... (2 Replies)
Discussion started by: compasscard
2 Replies

9. Shell Programming and Scripting

Shell script to move certain files on scheduled time

Hi Friends, I want a shell script which will move certain .jar files from a specified location (say /publish/content) to (/publish/archive) on every saturday morning 6 am. One more thing to add is that before moving files it must check free space at (/publish/archive), if it is more than 60 %... (7 Replies)
Discussion started by: abhishek27
7 Replies

10. Shell Programming and Scripting

Archiving by Time

Hi all. I am trying to set up archiving of directories, such that I keep every directory made in the past week, but just one directory per week beyond that. Using the find command, I can easily delete everything more than one week old, but can not figure out how to save one. Each directory... (4 Replies)
Discussion started by: aefskysa
4 Replies

Featured Tech Videos