hpasystems
asked on
using regular expression with slocate
Hello peeps,
I want to locate files matching a regular expression and can't get it working.
Example.....
locate files matching....
AAaabb11.txt
AAaacc11.txt
AAbbaa44.txt
by using: locate -r AA*.txt - or - locate --regexp=AA*.txt
I also tried locate --regexp=* AA*.txt
I have tried quoting and bracing but I'm not sure of what is required. man page is sparse.
Is locate able to match on specific expressions as per my example?
please help, I am not familiar with regular expressions other than what is already in place (learning by examples)
Cheers,
I want to locate files matching a regular expression and can't get it working.
Example.....
locate files matching....
AAaabb11.txt
AAaacc11.txt
AAbbaa44.txt
by using: locate -r AA*.txt - or - locate --regexp=AA*.txt
I also tried locate --regexp=* AA*.txt
I have tried quoting and bracing but I'm not sure of what is required. man page is sparse.
Is locate able to match on specific expressions as per my example?
please help, I am not familiar with regular expressions other than what is already in place (learning by examples)
Cheers,
And, more specifically, if your app supports it:
^AA.*\.txt$
^AA.*\.txt$
Try
AA??????.txt
AA??????.txt
if you only want to find files starting with AA....
find /path -type f -name "AA*txt" -print
find /path -type f -name "AA*txt" -print
ASKER
Hi, yes, I can use find, but want to use locate - or at least be familiar with using locate with a regular expression.
ddrudik,
So the locate command should look like....
locate --regexp=* AAA.*\.txt ??? This did not work.
Omarfarid,
Using AA??????.txt is no good, the variable can be different lengths.
Can anyone supply the exact syntax of using a regular expression for locate???
Thanks all for assist, please continue! :)
ddrudik,
So the locate command should look like....
locate --regexp=* AAA.*\.txt ??? This did not work.
Omarfarid,
Using AA??????.txt is no good, the variable can be different lengths.
Can anyone supply the exact syntax of using a regular expression for locate???
Thanks all for assist, please continue! :)
So, what about AA*.txt?
Do you have any particular criteria for the file name? What you have shown is of a fixed length.
Do you have any particular criteria for the file name? What you have shown is of a fixed length.
ASKER
yeah sorry, just realised my examples are misleading.
it needs to be like you say....
AA*.txt
...and how the command should actually look. I cannot get it to work. returns nothing.
locate -r AA*.txt <- obviously, I am missing something.
it needs to be like you say....
AA*.txt
...and how the command should actually look. I cannot get it to work. returns nothing.
locate -r AA*.txt <- obviously, I am missing something.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
From the man page it would seem you should skip regex altogether:
locate AA*.txt
locate AA*.txt
ASKER
Hi guys,
thanks for assist. My man pages are not very helpful, very baron. Also, the test machine isn't working but server I want it running on is and works with/without -r as suggested above. Only dirfference in versions...
did not work for...
Secure Locate 2.6 - Released May 21, 2001
on RHEL 2.1
did work for...
Secure Locate 2.7 - Released January 24, 2003
on RHEL4AS
Thanks guys, much appreciated.
thanks for assist. My man pages are not very helpful, very baron. Also, the test machine isn't working but server I want it running on is and works with/without -r as suggested above. Only dirfference in versions...
did not work for...
Secure Locate 2.6 - Released May 21, 2001
on RHEL 2.1
did work for...
Secure Locate 2.7 - Released January 24, 2003
on RHEL4AS
Thanks guys, much appreciated.
ASKER
Great response time.
Very helpful.
Very helpful.
AA.*\.txt