Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

find . -inum 3232 -exec rm -i {} \;

 
SOLVED
Go to solution
Highlighted
Regular Advisor

find . -inum 3232 -exec rm -i {} \;

I am executing this command.
I am expecting it to ask me whethere or not to delete the file. But, this is what I am getting.

# ls -i
3232 -l

# find . -inum 3232 -exec rm -i {} \;
rm: remove regular file `./-l'? #

As you can see, it is directly showing next command prompt without waiting for me to provide any input.
12 REPLIES 12
Highlighted
Honored Contributor
Solution

Re: find . -inum 3232 -exec rm -i {} \;

Prasad,

try this,

# ls -i
11521 -l
# find . -inum 11521
./-l
# find . -inum 11521 -xdev -exec mv {} rj \;
# ls
rj

regards,
Robert-Jan
Highlighted
Trusted Contributor

Re: find . -inum 3232 -exec rm -i {} \;

maybe you could try something like:

for file in `find . -inum 3232`; do
rm -i $file
done
Highlighted
Honored Contributor

Re: find . -inum 3232 -exec rm -i {} \;

What shell?? It is working fine for me. Try following.

find . -inum 3232 -exec rm -i "{}" \;
There is no substitute to HARDWORK
Highlighted
Respected Contributor

Re: find . -inum 3232 -exec rm -i {} \;

Hello,

Why not using directly :

find . -inum 3232 -ok rm {} \;

normally it should prompt you for accepting or not the command. look at the man page.

Regards
Pat
Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
Highlighted
Honored Contributor

Re: find . -inum 3232 -exec rm -i {} \;

Hello Prasad,

You can do this way,

# cat test.sh

for remove_file in `ind . -inum 3232`
do

rm -i $remove_file

done

# chmod 755 test.sh
# ./test.sh

-Arun

"A ship in the harbor is safe, but that is not what ships are built for"
Highlighted
Honored Contributor

Re: find . -inum 3232 -exec rm -i {} \;

Simply as,

# rm -i `find . -inum 3232`

will help you out.

--
Muthu
Easy to suggest when don't know about the problem!
Highlighted
Regular Advisor

Re: find . -inum 3232 -exec rm -i {} \;

Hi Robert-Jan Goossens,

I tried this.

# find . -inum 2275 -xdev -exec mv {} rj \;

find: warning: you have specified the -xdev option after a non-option argument -inum, but options are not positional (-xdev affects tests specified before it as well as those specified after it). Please specify options before other arguments.

# ls
rj

It seems it is working but, giving some warning messgaes.
Highlighted
Honored Contributor

Re: find . -inum 3232 -exec rm -i {} \;

Warnign message is OK. You were running into problem beause, you file had a "-" as char in it. So first moving it to another file and then removing it.
There is no substitute to HARDWORK
Highlighted
Regular Advisor

Re: find . -inum 3232 -exec rm -i {} \;

Hi All,

Thanks for instant replay.

The same can be accomplished with

1. for f in `find . -inum 2275`
do
rm -i $f
done

2. rm -i `find . -inum 3232`

3. find . -inum 3232 -ok rm {} \;

4. find . -inum 3232 -xdev -exec mv {} rj\;

Thanks a lot.