find files older than and containing then tar.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find files older than and containing then tar.
# 1  
Old 11-06-2009
find files older than and containing upper and lower case text then tar.

I'm tring to:

find files recursively older than x days that contain dat or DAT then tar them

I can find the files older than 90 days containing dat with this:

find . -mtime +90 -type f -name "*dat*" -exec tar -cvvfp /some/path/some.tar {} \;


but how do I do it case insensitive?

find . -mtime +90 -type f -name "*dat*" and "*DAT*" -exec tar -cvvfp /some/path/some.tar {} \;


EDIT: Im using HP-UX so there is no "-iname" for the find command.

---------- Post updated at 11:05 AM ---------- Previous update was at 10:19 AM ----------

I found that this would not work anyway.. It creates a new tar file everytime it finds a file.

But I did figure out how to do it.

tar cvvfp /path/to/some.tar `find . -mtime +90 -type f | grep -i "dat"`

Last edited by Ikon; 11-06-2009 at 01:42 PM..
# 2  
Old 11-06-2009
Sorry this is not much help. I always thought you could do something like:

find . \(-name '*.txt' -o -name '*.TXT'\) -print

But I've just tried it on my HP-UX and it gives:

find: bad option -o

man find
suggests -o is valid, though

expression -o expression Logical OR operator. True if either or
both of the expressions are true.


Good luck in finding your answer.
# 3  
Old 11-06-2009
Try this:

Code:
find /* -mtime +90 -type f -name "*dat*" -or -name "*DAT*" - exec tar -cvvfp /some/path/some.tar {} \;

Works for me on RH

Last edited by mkastin; 11-06-2009 at 02:32 PM..
# 4  
Old 11-06-2009
Seen my error! you can use this form of construct for your or clause if you wish. Have tested on HP-UX and it throws up my .txt and .TXT files

find . \( -name \*.txt -o -name \*.TXT \) -print
./env.txt
./dir.txt
./shella.txt
./taila.txt
./tailb.TXT
./number.txt
./finished.txt
./dir2.txt
./shellb.txt
./cutshellb.txt
./tailb.txt
./numberb.txt
./result_c.txt

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

2. UNIX for Dummies Questions & Answers

Find files older than 2010?

Hi, I need to delete all files, in a folder, older than 2010 that is 2009, 2008 ,.. files... Can anyone suggest the command for that,... Thanks ---------- Post updated at 03:29 PM ---------- Previous update was at 02:53 PM ---------- humm,.. ok right now I am using the following:... (4 Replies)
Discussion started by: Mack1982
4 Replies

3. Shell Programming and Scripting

Find files older than 8 hours

I need a script to find files older than 8 hours... I know i can use mmin but the same is not working...the same only support mtime... This is the script i created..but the same is only giving 1 hour old..as I have given dt_H as 1 only...but if i give 8..it can go in -(negative)..how to get the... (5 Replies)
Discussion started by: cotton
5 Replies

4. Shell Programming and Scripting

Need script to tar files older than 30 days

Hi all. Here's my situation: I have performance reports that run every 30 minutes saved in the format: stats_report_11251000.txt stats_report_11251030.txt stats_report_11251100.txt stats_report_11251130.txt (Obviously run at Nov 25 10 AM, 10:30 AM, 11 AM and so on...) I would... (2 Replies)
Discussion started by: jamie_collins
2 Replies

5. UNIX Desktop Questions & Answers

Find files older than 10 days

What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. find . -type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. (4 Replies)
Discussion started by: Pouchie1
4 Replies

6. Shell Programming and Scripting

How to tar, compress and remove files older than two days

Hi, I'm Eddy from Belgium and I've the following problem. I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands. The problem is that I do not find a good combination... (4 Replies)
Discussion started by: edr
4 Replies

7. Solaris

Find files older than x days and create a consolidated single tar file.

Hello, I need help in finding files older than x days and creating a single consolidated tar file combining them. Can anyone please provide me a script? Thanks, Dawn (3 Replies)
Discussion started by: Dawn Bosch
3 Replies

8. Shell Programming and Scripting

only find files older than x minutes old

I am looking for a way to show files that have been created within a certain period (say anything older than 10 minutes or so). Is there a command/series of commands I can do this with? As an example, I have the following in a directory: -rw-r--r-- 1 owner group 70175 May 16 09:10... (1 Reply)
Discussion started by: dsimpg1
1 Replies

9. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies

10. UNIX for Dummies Questions & Answers

tar files older than 30 days

Hi there, I am trying to tar a number of files held in a specific folder. I am only interested in archiving files older than 30 days. Having read through the man entries and all available documentation I thought I'd cracked the coomand with tar -c -z -v -N 15/04/2004 -f /wfch.tar * This... (6 Replies)
Discussion started by: wfch
6 Replies
Login or Register to Ask a Question