I have by a mistake written this command on a CentOS server

xargs rpm -e|rpm -qa|grep test11

where I meant

rpm -qa|grep test11|xargs rpm -e

which should uninstall all packages matching "test11".

Can someone figure out what the first command do? I am afraid that it un-install ALL packages =(

link|improve this question

feedback

2 Answers

up vote 7 down vote accepted

No worries, it just executed 'rpm -e' which would not remove any package.

[root@web420 ~]# rpm -e
rpm: no packages given for erase

BTW, for verifying you have not removed all packages you could just run

rpm -qa

and see the list of installed packages.

link|improve this answer
1  
As long as you specified no input to xargs "rpm -e" should bail out with an error message and the rest of the chain "does nothing" (at least in terms of modification) – voretaq7 Feb 8 '10 at 18:23
4  
For the future, specify --test to potentially-destructive RPM commands (like -e): It will tell you what it's going to do without actually changing your system so you can avoid unplesant surprises. – voretaq7 Feb 8 '10 at 18:24
@voretaq7 great point! – Saggi Malachi Feb 8 '10 at 18:29
@voretaq7: Excellent trick. I will clearly use that from now on =) – Sandra Feb 10 '10 at 12:11
By the way: if you removed all packages from RHEL, it wouldn't run at all! Everything is a package, right down to the filesystem layout. – David Jan 13 '11 at 22:25
feedback

The first command you gave will not remove all packages (phew!). Here is the command you gave:

xargs rpm -e|rpm -qa|grep test11

The command rpm -e does remove RPMs, but with xargs listed without a pipe, it takes its input from the terminal and waits for your input. The second command would essentially replace the output from rpm -e with rpm -qa (all RPMs) then find the RPM test11 (if it exists).

Not a command string worth running, but certainly one worth understanding...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.