find: unknown predicate `- filesdpx/2024-01-28/dtx_2024-04-10_reference.txt
I want to find all files in a directory called 'project' inside this directory there is a lot of different directory with the criteria */*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path 'Archive/*' -not -path 'orphan'. After finding the files with the mentioned criteria, I want those files to be moved to the 'files.txt' file. However, while running this script: find */*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path 'Archive/*' -not -path 'orphan/*' > files.txt
I am getting the error 'unknown predicate for find command,' which indicates that certain files have a hyphen at the beginning and a space between the hyphen and the filename. How can I fix that? I ran this line in a bash script. |
I'd try running the command with quotes/double quotes around the entire path.
|
Is there a hyphen followed by a space in the command itself? That’s what the error you describe seems to indicate.
Use code tags to show us exactly what you ran, please. Also what, exactly, the message you got said. |
you can add an echo:
Code:
echo find */*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path 'Archive/*' -not -path 'orphan/*' |
hey @yancek i added the quotation but nothing changed , still have the same error .
|
Quote:
no there is no any hyphen in the command , i was looking for files older than 180 days with the name convention 20 into specific directory , but there is an error with one directory that has a hyphen at the beginning and space in between the hyphen and the directory name , the find command is not able to go into that directory and look for files complaining about the - i am not sure how to make the find command deal with hyphen or special character to find for the files into that directory . |
Quote:
|
Quote:
Code:
find */*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path 'Archive/*' -not -path 'orphan/*' > files.txt So, again. Please copy/paste the command that’s erroring into code tags (see the link in my sig), and include the error you’re getting. Don’t tell us what’s happening, show us. Please. |
Quote:
Try: Code:
find ./*/*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path 'Archive/*' -not -path 'orphan/*' > files.txt |
and the -path names must adapt:
Code:
find ./*/*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path './Archive/*' -not -path './orphan/*' > files.txt Code:
find ./*/*/*20* -maxdepth 1 \( -path './Archive' -type d -or -path './orphan' -type d \) -prune -or -type f -mmin +$((730 * 1440)) > files.txt Both -or branches have a default -print action. An explicit -print only prints that branch: Code:
find ./*/*/*20* -maxdepth 1 \( -path './Archive' -type d -or -path './orphan' -type d \) -prune -or -type f -mmin +$((730 * 1440)) -print > files.txt Code:
find . -maxdepth 1 \( -path './Archive' -type d -or -path './orphan' -type d \) -prune -or -path './*/*/*20*' -type f -mmin +$((730 * 1440)) -print > files.txt |
All times are GMT -5. The time now is 05:43 AM. |