HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with the command rm

 
Goriik
Advisor

Problems with the command rm

I'm trying to delete a large number of logs. There is a confirmation of 8583pos_int.out: 640 mode? (y / n) n. How to make the removal occurred without confirmation?


user@server:~> alias | grep cle
alias cle='(cd ~/output/log; rm *; close_out all;)'
alias mqq='while [ 1 ]; do clear; mq; sleep 3; done;'

user@server:~/output/log> rm *
8583pos_int.out: 640 mode ? (y/n) n
8 REPLIES
Horia Chirculescu
Honored Contributor

Re: Problems with the command rm

Did you tried with rm -f * ?

Horia.
Best regards from Romania,
Horia.
Kapil Jha
Honored Contributor

Re: Problems with the command rm

if you sure you have to delete files just run #rm -f

over here I suppose you are not the owner of the file or root??

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Goriik
Advisor

Re: Problems with the command rm

Owner, but not root.

Modris Bremze
Esteemed Contributor

Re: Problems with the command rm

And what about directory permissions - you need rwx to rm something in it.
Kapil Jha
Honored Contributor

Re: Problems with the command rm

still I would think rm -f should work.

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

Re: Problems with the command rm

Just....

rm -f * is probably the most dangerous command in any UNIX, worse than a reboot.
I have learned not to use * with rm :)
use it wisely, it really sucks sometimes.

BR,
Kapil+
I am in this small bowl, I wane see the real world......
madhuchakkaravarthy
Trusted Contributor

Re: Problems with the command rm

HI

check the permission....

regards

MC
RC Park
Frequent Advisor

Re: Problems with the command rm

Suggestion:

Being anal, as any good admin should be about using rm, you're much better off creating an object list that you verify and edit then process through a simple command line that will rm the files. WAY more safe than just issuing rm at the command line with wild cards.

For example:
1. create the list by using ls and sending output to a file such as /tmp/flist1

> ls -1 >/tmp/flist1

2. edit the list to be sure only files you want deleted are in the file

> vi /tmp/flist1

3. run a command to process the list

> cat /tmp/flist1|xargs -i rm -f {}

The above command will rm the object {} which gets sent to the {} by xargs processing each line of the file /tmp/flist1

BEST way, IMHO. Also, you can then cp the file to /tmp/flist2, chop all but the first 5 lines and run the above as a test to see if it works.

-RCP