"Find: Paths Must Precede Expression:" How to Specify a Recursive Search That Also Finds Files in the Current Directory

find: paths must precede expression: How do I specify a recursive search that also finds files in the current directory?

Try putting it in quotes -- you're running into the shell's wildcard expansion, so what you're acually passing to find will look like:

find . -name bobtest.c cattest.c snowtest.c

...causing the syntax error. So try this instead:

find . -name '*test.c'

Note the single quotes around your file expression -- these will stop the shell (bash) expanding your wildcards.

find: paths must precede expression

Quote your shell arguments:

$ ./findfiles.sh /var/log/ '*.txt'

Why does find command in if return paths must precede expression error?

The problem are the date variables - and if you had read find's output correctly you would have noticed that, too.

if test -n "$(find . -iname 'PAY*.txt' -newermt "$p_date1" ! -newermt "$p_date2" -print)";

Note the double quotes around the variable names.

find: paths must precede expression: find -name

ssh uses system(3) semantics and not execve(2) semantics.

In other words, you need to add a layer of escaping:

sshpass -p bagabu ssh -q root@localhost "find /opt/ -iname '*.log*'"

find: paths must precede expression: `1'

That error is shown when a stray argument is found on the command line, which is 1 in this case, as -d (i.e -depth) doesn't take an argument. However, it seems that you don't need find here at all.

for dir in ./*/; do
make -C "$dir" clean &&
make -C "$dir" &&
cp "$dir/main.bin" "$dir.bin" &&
make -C "$dir" clean
done


Related Topics



Leave a reply



Submit