command usage on find with xargs and tar


 
Thread Tools Search this Thread
Operating Systems AIX command usage on find with xargs and tar
# 1  
Old 12-19-2007
command usage on find with xargs and tar

my task : tar up large bunch of files(about 10,000 files) in the current directories that created more than 30 days ago
but it come with following error

find ./ -ctime +30 | xargs tar rvf test1.tar
tar: test1.tar: A file or directory in the path name does not exist.
# 2  
Old 12-19-2007
If the tar file does not exist you cannot update it!

So I would create the tar file first adding a single readme file describing what it contains, then do what you were going to do.

However, for sanities sake, use find to create the list of files, then you will have a record of what you were putting in the tar file, so if you need to move or delete them you can do so from that list.

Also, you don't want the tar file itself to be included.
# 3  
Old 12-23-2007
Quote:
Originally Posted by porter
If the tar file does not exist you cannot update it!

So I would create the tar file first adding a single readme file describing what it contains, then do what you were going to do.

However, for sanities sake, use find to create the list of files, then you will have a record of what you were putting in the tar file, so if you need to move or delete them you can do so from that list.

Also, you don't want the tar file itself to be included.

thank for your reply, it work with your recommandation but it is kind of weird way to make it work in my mind. Smilie
# 4  
Old 12-25-2007
When you use find already, what do you need xargs for? Just a suggestion: use the -exec clause in find:

find . -ctime +30 -exec tar -rvf test1.tar {} \;

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find command and multiple * usage

Please can i use: find /home/username/public_html/_sub/*/wp-content/*cache* -type f -delete command to empty all folders contianing "cache" in wp-content directory. issue is that in /home/username/public_html/_sub/ i have around 50 folders and i want to use this rule on all of them, so im... (3 Replies)
Discussion started by: postcd
3 Replies

2. Shell Programming and Scripting

Fast processing(mv command) of 1 million+ files using find, mv and xargs

Hi, I'd like to ask if anybody can help improve my code to move 1 million+ files from a directory to another: find /source/dir -name file* -type f | xargs -I '{}' mv {} /destination/dir I learned this line of code from this forum as well and it works fine. However, file movement is kinda... (6 Replies)
Discussion started by: agentgrecko
6 Replies

3. UNIX for Dummies Questions & Answers

Usage of find command

I need to find a file that has been modified in last 3-4 hours. mtime tells us about file modified in n days. Is there any way I can check for hours or minutes file modified or created before. (5 Replies)
Discussion started by: ankush_mehra
5 Replies

4. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

5. UNIX for Advanced & Expert Users

tar command usage

1. command tar cf abcd.tar *.prn There is no *.prn files in the path, eventhough it is creating the abcd.tar. Can anyone tell me how can i resolve this problem? (2 Replies)
Discussion started by: kingganesh04
2 Replies

6. UNIX for Dummies Questions & Answers

use of xargs and prune piping with find command.

Can anyone interpret and tell me the way the below command works? find * -name "*${msgType}" -mtime +${archiveDays} -prune -type f -print 2>/dev/null | xargs rm -f 2> /dev/null Please tell me the usage of prune and xargs in the above command? Looking forward your reply. Thanks in... (1 Reply)
Discussion started by: venkatesht
1 Replies

7. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

8. Solaris

Usage find command

is there any way to search the file using find command, so that it searches for the file considering the file name as case in-sensitive For example file name is AbcD.txt but i'm not sure of the file name just remember it was abcd.txt find / -name "abcd.txt" -print how do we go bout the... (2 Replies)
Discussion started by: raman1605
2 Replies

9. UNIX for Advanced & Expert Users

find command usage

I usually ise find to search a file or name on the unix, since I am not administrator, there will be many line appear 'cannot access',usually a hundred of lines. How can I prevent this line coming out? only show I want? The command I use is : find / -name abcdef -print Thank all expert. (1 Reply)
Discussion started by: zp523444
1 Replies

10. UNIX for Advanced & Expert Users

How to use the command Tar to find a file

Hello, I am just using the command Tar to find if a file was backuped on my tape. Can you help me with that command. I am using the command : tar -tvf /dev/rmt/4m /kcc_dms/AC7/c15a* > toto.txt to find all files c15a* in these subdirectories on my tape. But it doesn't work correctly. Can... (2 Replies)
Discussion started by: steiner
2 Replies
Login or Register to Ask a Question