Find command problem

Hi All,

I am using following find command to delete the records older than 7 days but getting missing conjuction error.Kindly suggest:

The command is:

find <complete_dir_path> \(! -name usr -prune \) -type f -name "*.txt" -mtime +6 -print | xargs rm

find <complete_dir_path>

-type f -name "*.txt" -mtime +6 -print | xargs rm

what is that for???

to search the current directory only

but when you provide the complete dir path for find command it will look into that dir only.. so what do you mean by current dir??

I don't want to search in the directories starting from "usr".Thus, using the prune option. Could u please suggest whjy am i getting the missing conjuction error.

that is because after -name usr must be in double quote

try this

No luck..it didn't work this was as well.

The reason is that "\(" cannot be correctly parsed if not surrounded by spaces. Therefore ".... \( ! ...." will work, but "... \(! ..." won't. For similar reasons "if [$x -ge 5 ]" won't work either, but will if you insert a space between the "[" and the "$", etc..

Btw., using "-exec" instead of "-print" only to pipe it to xargs is highly recommended.

I hope this helps.

bakunin

missing conjuction error will usually come when there is missing quotes..

I have introduced the space but it is still not working.

Hi baunin,

Your solution worked (it has removed the missign conjunction error)but the find is still giving me the count of files present in "usr" directory.

I want to search only in the current directory for *.txt files(there are sub-directories whcih also contains *.txt files). I have tried few things but in vain.

Please suggest.

GIYF

When i entered "find -prune" in the search feature here the third thread was this: Find command to run only in the base directory where exactly your question was asked and subsequently answered.

I hope this helps.

bakunin