Program to search for the files with specific format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Program to search for the files with specific format
# 8  
Old 03-08-2017
Hi Don,

Thank you.
Would be helpful if you can provide an example to use find -ctime. I need to lst the file which created from 06-MAR-2017 to 08-MAR-2017.


Code:
$ find . -ctime ABC_P_070317.txt
find: Specify a decimal integer for -ctime
Usage: find [-H | -L] path-list [predicate-list]

Thanks
Bharat
# 9  
Old 03-09-2017
Isn't that error message self explaining?

As the -ctime argument specifies an interval of n*24h (counted from NOW) and not an absolute date, the command depends on the date/time it is run for today, 9.3.2017, it looked like
Code:
find . -ctime +0 -ctime -2 -name "ABC_P_*.txt"

(but cf man find for peculiarities). To specify intervals less than a day, consider the -cmin test.
This User Gave Thanks to RudiC For This Post:
# 10  
Old 03-09-2017
When you want to specify a range of times that is related to the start of a day instead of something that is a multiple of 24 hours from the time when you run your script, also consider using touch to create files with the starting and ending timestamps and using find's -newer primary a couple of times...
Code:
trap 'rm -f /tmp/start.$$ /tmp/end.$$' 0
touch -t 201703060000 /tmp/start.$$
touch -t 201703090000 /tmp/end.$$
find . -newer /tmp/start.$$ ! -newer /tmp/end.$$ -name 'ABC*' -name '*_I_*'

This User Gave Thanks to Don Cragun For This Post:
# 11  
Old 03-13-2017
Thank you Don and Rubi. I am working on the solution based on your inputs. will post the code once its ready.

Thanks
Bharat
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running program and output files in specific directories

I have been running a program mseed2sac using the following command cd IV find . -type f -exec /swadmin/mseed2sac '{}' \; The problem is that I end up with a lot of files in directory IV. Instead I would like to select the designator HHZ, create a directory IV.SAC and all the files output... (11 Replies)
Discussion started by: kristinu
11 Replies

2. Shell Programming and Scripting

To find files having filename containing specific date format

Hi, I have a requirement to create a shell script(tcsh) that finds all the files in a directory having the file name containing date format "YYYYMMDDHHMM" and extract the date time part ""YYYYMMDDHHMM" for further processing. Could you please have any idea on this. trades_201604040000.out... (6 Replies)
Discussion started by: gopal.biswal
6 Replies

3. UNIX for Dummies Questions & Answers

Printing files in a specific format

Hi, I have following files in a directory with '.meta' extension, which have data in follwoing patterns. i need to print data from these files in below metioned format. please provide a script for this solution. file names: TEST_HISTORY_MTH.meta AB_TEST_1.meta cat... (2 Replies)
Discussion started by: AAHinka
2 Replies

4. Shell Programming and Scripting

search for content in files. Name of files is in another file. Format as report.

Hi I have multiple files in a folder and one file which contains a list of files (one on each line). I was to search for a string only within these files and not the whole folder. I need the output to be in the form File1<tab>string instance 2<tab> string instance 2<tab>string instance 3... (6 Replies)
Discussion started by: pkabali
6 Replies

5. UNIX for Dummies Questions & Answers

How to search all the files in a directory for a specific string

Hi Guys, I want to search the content of all the files (of a particular type like .txt) in a directory for a specific string pattern. Can anyone help me? Thanks (7 Replies)
Discussion started by: mwrg
7 Replies

6. Shell Programming and Scripting

search files without a specific text

Hi all, I need UNIX command that would give me all files without the string "4R" anywhere in the file. I have about a hundred files in my directory, and I need to list all files wihtout the string "4R" anywhere. Can anyone help me please? Thank you.l (4 Replies)
Discussion started by: risk_sly
4 Replies

7. Shell Programming and Scripting

Help make a program in cshell that searches and prints in a specific format

say I have a file named phones in that file every line is like that lastname^firstname^phone how can I make a program in cshell that searches for a specific string in phones and echos the result (if found) like that: lastname1 firstname1 phone1 ------------------ lastname2 firstname2... (8 Replies)
Discussion started by: h4wk
8 Replies

8. Shell Programming and Scripting

Search files that all contain 4 specific words

Hello, I want an one line command that brings me back all the files in a folder that contain 4 specific words anywhere inside them. I want to use find,xargs and grep. for example i know for one word the command would be: find . | xargs grep 'Word1' But i don't know for 4 specific words... (13 Replies)
Discussion started by: WoodenSword
13 Replies

9. UNIX for Dummies Questions & Answers

How to search files containing a specific word in the content

Hi all, Lets say I have 3 files a.txt and b.txt and c.txt. a.txt has the following text ==================== apple is good for health b.txt has the following text ==================== apple is pomme in french c.txt has the following text ==================== orange has citric acid... (1 Reply)
Discussion started by: amjath78
1 Replies

10. UNIX for Dummies Questions & Answers

Search all files for specific string

Hi Friends, How can I search all files in all slices on a unix system for a particular string within the file. e.g search string 'oracle' Thanks (4 Replies)
Discussion started by: sureshy
4 Replies
Login or Register to Ask a Question