Operating System - Tru64 Unix
1748042 Members
4970 Online
108757 Solutions
New Discussion юеВ

find command problem

 
SOLVED
Go to solution
fergani
Advisor

find command problem

Hi all
I am using tru64 unix.
I executed this command form root
and received an error message.
The command is :-
#find / -name *.sql -exec \ rm {} \;
The error is:-
#find:cannot execute rm command.

could anyone help me please.
bye.
3 REPLIES 3
Steven Schweda
Honored Contributor
Solution

Re: find command problem

> #find / -name *.sql -exec \ rm {} \;

Try something like:

find / -name '*.sql' -exec rm {} \;

You need to protect the "*" from the shell.
I don't know what that first "\" was supposed
to do for you.

But I'd run it once without the "rm" stuff,
to make sure that it will find and delete
only what you wish to have deleted. Or,
add "-i" to the "rm" command:

find / -name '*.sql' -exec rm -i {} \;
Kapil Jha
Honored Contributor

Re: find command problem

try
find / -name *.sql -exec rm {} \;

or
find / -name *.sql | xargs rm

be lil careful you using * which mean everything ;)

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Steven Schweda
Honored Contributor

Re: find command problem

> try
> find / -name *.sql -exec rm {} \;

Not quoting the "*" wildcard here is a Really
Bad Idea (tm). For example:

urtx# pwd
/root

urtx# ls -l *.tar
-rw-r--r-- 1 root system 20480 Jun 5 2007 tt_gnu.tar
-rw-r--r-- 1 root system 10240 Jun 5 2007 tt_t64.tar

urtx# find /root -name *.tar -ls
find: missing conjunction

urtx# find /root -name '*.tar' -ls
2507 20 -rw-r--r-- 1 root system 20480 Jun 5 2007 /root/tt_gnu.tar
2506 10 -rw-r--r-- 1 root system 10240 Jun 5 2007 /root/tt_t64.tar
2322 13 -rwxr-x--- 1 nobody nobody 12800 Jun 6 2007 /root/tt2/tt_gnu_x.tar


> You need to protect the "*" from the shell.

Still true, in general. Although you may get
lucky from time to time, you need to decide
how much you wish to depend on luck.