"find": search the a regex of FILES??


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers "find": search the a regex of FILES??
# 1  
Old 03-11-2010
"find": search the a regex of FILES??

I want to use the find command to search a ton of files, but I want to break it up into multiple machines. I want to search for files with "filename." in the title.
The location I want to search is:
Code:
/u/*/*/*/stuff

On the first computer I want to search:
Code:
/u/[a-i]/*/*/stuff

Right now I am doing
Code:
find /u/*/*/*/stuff -iregex "/u/[a-i]/.*filename\..*" -print >>~/Desktop/find

This works correctly on the first machine, but for the second machine i will be searching [j-p] and in this case it will still search a-i first. I really want to do something like:
Code:
find /u/[j-p]/*/*/stuff -iregex ".*filename\..*" -print >>~/Desktop/find


Anyone know if/how I could do this?
# 2  
Old 03-12-2010
specify a list of directory names for find to look through
Code:
find u/1/2/3 u/a/b/s u/2/3/4/5  -type f -name '*filename*' -exec ls -l {} \;

the bracket [a-j] may not work on all unix machines.

If you have a gigantic list of directories put all of the directory names into a file, call it dirnames:
Code:
find $(awk '{printf(" %s ", $0)}' dirnames) -type f -exec ls -l {} \;

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find files in sub dir with tag & add "." at the beginning [tag -f "Note" . | xargs -0 {} mv {} .{}]

I am trying find files in sub dir with certain tags using tag command, and add the period to the beginning. I can't use chflags hidden {} cause it doesn't add period to the beginning of the string for web purpose. So far with my knowledge, I only know mdfind or tag can be used to search files with... (6 Replies)
Discussion started by: Nexeu
6 Replies

2. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

3. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

4. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

5. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

6. Shell Programming and Scripting

bash: How to reuse the search result of "find"

find . -type f -print0 | xargs -0 chmod 600 find . -type f On bash, I would like to pass the search result of "find" to another command as well as to the standard output. The above code performs the same search twice -- once for "xargs -0 chmod" and another for stdout. I would like to... (5 Replies)
Discussion started by: LessNux
5 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

find: "weird" regex behaviour

I have these two files in current dir: oos.txt oos_(copy).txt I execute this find command:find . -regex './oos*.txt'And this outputs only the first file (oos.txt)! :confused: Only if I add another asterisk to the find find . -regex './oos*.*txt' do I also get the second file... (7 Replies)
Discussion started by: courteous
7 Replies

9. UNIX for Dummies Questions & Answers

How to use the "grep/egrep" command to search files.

Hi Team, I am new to this forum and also trying to learn Unix. I will highly appriciate your help if you can help me to get the right command . {{{ I use the command " today | egrep '(10:| 11: )' | grep ERROR " to grep all the files that has been error betweeen 10 to 11... (6 Replies)
Discussion started by: rkhanal
6 Replies

10. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies
Login or Register to Ask a Question