Reputation: 237
Hello the below is not removing the files that are ending with char 'o' but I'm not sure why.
find . -name '.*o' -type f -ok rm '{}'
here is my current error
Thanks so much!!
Upvotes: 0
Views: 143
Reputation: 904
While Jatinj Mehrotra is correct, there are still two things unmentioned:
-exec
and -ok
are simmilar, but not the same. -exec
will execute your command on every file find
finds. -ok
will actually ask you for every single file or directory, if you are ok
with executing the command on it.\
befor your ;
. In shell the semi-colon is a delimiter for a command. So command1; command2
will be interpreted as if you typed command1
, then pressed enter, and then typed command2
and press enter. But in this case the semicolon is actually a parameter to find -exec
. It tells find
that you want that command executed on every single item individually. You can also use a +
, which tells find to replace the {}
with a space-seperated list of everything it finds.Upvotes: 0
Reputation: 11513
This worked for me
find . -name '*o' -type f -exec rm -f {} \;
Upvotes: 2