Need help to identify files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help to identify files
# 1  
Old 12-03-2009
Need help to identify files

Hi,

I have one problem. I want to identify all those files which are named according to the format <name>_<date>. I have tried using awk and grep in bash but i m not able to get it correct.

Can someone please help? It's urgent !!
# 2  
Old 12-03-2009
Depends on the format of the date.
You should be more precise about the format of the files
# 3  
Old 12-03-2009
yeah ..sorry for that..suppose i have abc_04Jul2009.txt kind of files apart from abc.txt files in my directory.

Now, i want to display those files which are named according to <name>_<date> format..with the date format given above..

Please I need help on this.

I have tried this:

ls | grep "_" | grep "`date +%d%B%Y`"

But this gives only for today's date. I want for all other dates also.
# 4  
Old 12-03-2009
You can try
Code:
ls | grep '_[0-3][0-9][A-Z][a-z][a-z][1-2][0-9][0-9][0-9].'

But it doesn't verify if the alpha characters correspond really to a month but a 3 char string with first letter uppercase.

Last edited by frans; 12-03-2009 at 07:33 AM.. Reason: precisions
# 5  
Old 12-03-2009
yeah..thats the exact problem..i have tried regular expressions for that also but couldn't figure it out..one of my friends said to use awk for this..but unable to figure it out..
# 6  
Old 12-03-2009
another way could be to loop in the files, extract the substring corresponding to the position of the date, then test th evalidity with somthing like date -d "...".
Is the string before date always of the same length ?
# 7  
Old 12-03-2009
ls | grep [a-z]*_[0-9][0-9][A-Z][a-z]*[0-9][0-9][0-9][0-9].[a-z]*
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare multiple files, identify common records and combine unique values into one file

Good morning all, I have a problem that is one step beyond a standard awk compare. I would like to compare three files which have several thousand records against a fourth file. All of them have a value in each row that is identical, and one value in each of those rows which may be duplicated... (1 Reply)
Discussion started by: nashton
1 Replies

2. Shell Programming and Scripting

Bash script to find the number of files and identify which ones are 0 bytes.

I am writing a bash script to find out all the files in a directory which are empty. I am running into multiple issues. I will really appreciate if someone can please help me. #!/bin/bash DATE=$(date +%m%d%y) TIME=$(date +%H%M) DIR="/home/statsetl/input/civil/test" ... (1 Reply)
Discussion started by: monasharma13
1 Replies

3. Shell Programming and Scripting

Perl Script to identify files without extension and assign a value

Hi, I have a perl script which is a part of a shell script which read lines from a flat file(which is generated as part of a script after a series of bteq/fexp) and assigns a value for each object in the file based on the type of file name. (i.e extensions like .bteq/.ctl/.ksh etc) For example,... (1 Reply)
Discussion started by: yohasini
1 Replies

4. Shell Programming and Scripting

identify files with "Normal termination" and compress them into a .tar.gz file

Hi, I have hundreds of files "*.out" located in one folder, and I want to: 1. Identify the good files containing "Normal termination" (grep "Normal termination" *.out ) 2. Compress the good files into a tar.gz file (tar cvfz good.tar.gz *.goog.out ) Is there a way I can automate this... (4 Replies)
Discussion started by: rockytodd
4 Replies

5. Shell Programming and Scripting

Using an awk script to identify dupes in two files

Hello, I have two files. File1 or the master file contains two columns separated by a delimiter: a=b b=d e=f g=h File 2 which is the file to be processed has only a single column a h c b What I need is an awk script to identify unique names from file 2 which are not found in the... (6 Replies)
Discussion started by: gimley
6 Replies

6. Shell Programming and Scripting

Identify log files based on time stamp,zip and then copy..HELP

Hi All, PFB is a requirement. I am new to shell scripting. So plz help. It would be highly appreciated. 1. choose all the log files based on a particular date (files location is '/test/domain')--i.e,we should choose all the files that are modified on 29th November, neither 28th nor 30th 2.... (3 Replies)
Discussion started by: skdas_niladri
3 Replies

7. Shell Programming and Scripting

Shell script to identify the number of files and to append data

Hi I am having a question where I have to 1) Identify the number of files in a directory with a specific format and if the count is >1 we need to concatenate those two files into one file and remember that in the second file the header should not be copied. it should be form first file.... (4 Replies)
Discussion started by: pradkumar
4 Replies

8. UNIX for Dummies Questions & Answers

To identify process

i want a command to display all the process running for partical user and in all process i want to see only particular process details.. pls suggest comand like ps -ef (1 Reply)
Discussion started by: Babu154
1 Replies

9. Shell Programming and Scripting

how do I identify files with characters beyond a certain range.

I have a directory with hundreds of files that can not have data pass column 80. I do not know of way to combine "grep" and "cut" command. I tried: cat * | cut -c 81-120 |pg but it only shows me the line, not the file name. Any help would be appreciated. Been on this all... (3 Replies)
Discussion started by: kcsunsun01dev
3 Replies

10. UNIX for Dummies Questions & Answers

how to identify files I cannot access

I want to use find (or something else) to give me a list of all files in a directory tree where the group access is not rwx or rw-. I'm trying to archive the whole directory tree, but it won't archive any files where I do not have at least read access. I have tried: find . ! -perm -060 but... (4 Replies)
Discussion started by: wvdeijk
4 Replies
Login or Register to Ask a Question