I want to search a directory for some files using find and a regular expression.
If I do
cd dir
find -E . -type f -regex '^\..*[^~]'
I get a list of files in the directory that match the the regular expression.
However, if I do
find -E ~/dir -type f -regex '^\..*[^~]'
i.e.
find -E /home/adam/dir -type f -regex '^\..*[^~]'
I get no output. How do I specify the directory to be searched by find when using a regular expression?
This is BSD find, as I am on a Mac.
~/dirin my question to$HOME/dir, so you might want to update your answer accordingly. At any rate, thanks for the help! – Adam Liter Jul 20 '14 at 05:43$HOMEinstead of~. At least quote it. – Gilles 'SO- stop being evil' Jul 20 '14 at 05:54find ~/dirin your answer rather thanfind $HOME/dir, as is now in my question. I do agree that there doesn't seem to be much of a point in using$HOMEinstead of~. All that being said, maybe these comments are now enough so that users won't be confused by the discrepancy, and you can leave your answer as is. Thanks again! – Adam Liter Jul 20 '14 at 06:02