Visit The New, Modern Unix Linux Community

Regex in find command

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Regex in find command
# 1  
Regex in find command


I need to find out the files whcih contains date in YYYYMMDD in their name.

I don't know if I can use regex in side find.

Now I am using commad for the same purpose which is not full proof.

find . -name "*[0-9][0-9]*" -print

But I want then It should contain at lease 8 digit in their names.
I tried with
find . -name "*[0-9][0-9]{8}*" -print

but no luck. Any idea....

Siba S Nayak

Last edited by siba.s.nayak; 11-23-2010 at 08:23 AM..
# 2  
Try something like:
find -name "*[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]*"

This User Gave Thanks to Franklin52 For This Post:
# 3  
I would use sed
find . | sed -n '/[0-9]\{8\}/p'


Last edited by Scott; 11-23-2010 at 02:30 PM.. Reason: Code tags
# 4  
Just for completeness I think some versions of 'find' support extended/perl regexp. This works with GNU findutils:

find . -regextype posix-extended -regex '.*[0-9]{8}.*' -print


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

Test Your Knowledge in Computers #175
Difficulty: Medium
ENIAC was one of the first electronic computers and occupied 167 square meters, weighed 27 tons and consumed 150kW of electricity.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

2. UNIX for Dummies Questions & Answers

Find command and regex

Hi All, We have to copy some files from a source directory to a destination directory. We only have to copy the file if the filename is in a list of values. We can use find command: find . -type f -name '*_111.txt' -o -name '*_115.txt' ... -exec cp {} /tmp \; But the list contains... (3 Replies)
Discussion started by: bartleby
3 Replies

3. Shell Programming and Scripting

what's wrong with my regex using find

#ls json-* json-lexer.c json-lexer.h json-parser.c json-parser.h json-streamer.c json-streamer.h #find . -regex '^(json-)+.' return nothing (3 Replies)
Discussion started by: yanglei_fage
3 Replies

4. UNIX for Dummies Questions & Answers

Using regex in find command

I don't understand why the following simple command is not working: find assign{1,2}Variations don't work, either: find assign+ find assign? ls assignAll I am trying to do is make an alias for running a C++ program of the name assign# or assign##. But the regular expressions aren't working. @_@... (27 Replies)
Discussion started by: Zucriy Amsuna
27 Replies

5. Shell Programming and Scripting

regex help with 'find'

How to do alternation using regular expressions in the 'find' command? Like say you want to find all files that do not match the names specifically "this" or "that" within a directory using regular expressions? (10 Replies)
Discussion started by: stevensw
10 Replies

6. Shell Programming and Scripting

Find directories by regex

Hello, I want to check if directories exist with a regex expression dir1=/temp/local/*/home (exists on file system) dir2=/temp/server/*/logs (does not exist on file system) I want to check if there are any directories with the above regex Code: if ];then echo "Directory... (4 Replies)
Discussion started by: gogineni
4 Replies

7. Shell Programming and Scripting

find regex and remove #

hi , how do i remove # from a line where i found regex.. don't need to remove all the line.. only remove comment.. (3 Replies)
Discussion started by: Poki
3 Replies

8. Shell Programming and Scripting

Find regex

Hi There, Can anybody help me out for searching this regular expression? xxxxx.yyy.zzzz.From-ABCD.To-XYZ.xxxxxx I would like the ID1 and ID2 (knowing which one is Id1 and id2) .From-<ID1>. and .To-<ID2>. Thanks in advance!! Regards, Bhaskar (4 Replies)
Discussion started by: bhaskar_m
4 Replies

9. Shell Programming and Scripting

Find with RegEx

I have some files in unix ls -1 TMH.backend.tar.421E-03.Z TMH.backend.tar.421E-04.Z TMH.backend.tar.421E-05.Z TMH.backend.tar.421E-06.Z TMH.backend.tar.421E-07.Z TMH.backend.tar.421E-08.Z TMH.backend.tar.421E-08.Z.bak20081223164844 TMH.backend.tar.421E-09.Z... (1 Reply)
Discussion started by: on9west
1 Replies

10. Shell Programming and Scripting

dont't find right regex

I have a string which contains following information: <SZ.T><P ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="+3">Bundesregierung nimmt sich dicke Deutsche vor</FONT></P></SZ.T> <SZ.UT><P ALIGN="CENTER"><FONT SIZE="+1"><I> Seehofer und Schmidt planen Kampagne gegen... (3 Replies)
Discussion started by: trek
3 Replies

Featured Tech Videos