find files older than and containing then tar.


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find files older than and containing then tar.
# 1  
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 02:42 PM..
# 2  
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  
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 03:32 PM..
# 4  
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 for Dates, Times and to Reply

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

Test Your Knowledge in Computers #2
Difficulty: Easy
Unix was invented by Steve Jobs of Apple Computer.
True or False?

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. Shell Programming and Scripting

Find older files than specified date

Hi, I need to find out list of files which are older than specific date. I am using 'find, and newer' commands but its not giving the correct result. Can you please help to findout the list of files. thanks (2 Replies)
Discussion started by: Satyak
2 Replies

3. UNIX for Advanced & Expert Users

find files older than 30 days old

Hello, I have a script which finds files in a directory that are older than 30 days and remove them. The problem is that these files are too many and when i run this command: find * -mtime +30 | xargs rm I run this command inside the directory and it returns the error: /usr/bin/find:... (8 Replies)
Discussion started by: omonoiatis9
8 Replies

4. 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

5. 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

6. 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

7. 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

8. 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

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

Featured Tech Videos