[Ilugc] .a-tip-a-day. xargs command

  • From: mbchandar@xxxxxxxxx (balachandar muruganantham)
  • Date: Mon Sep 21 09:47:59 2009

On Sat, Sep 19, 2009 at 5:04 AM, Girish Venkatachalam <
girishvenkatachalam@xxxxxxxxx> wrote:

Guys,

If I repeat what Bharathi sent long ago please excuse me. I can't help it.

xargs is often used with the find command like this.

$ find /etc | xargs vi

is a simple way to edit all files under /etc recursively including
directories. This is better.

$ find /etc -type f | xargs vi

You can also remove all .svn or CVS files like this.

$ find . -type d -name CVS | rm -rf

or

$ find . -type d -name .svn | rm -rf

I will send UNIX commands. Not just linux ones.


i use xargs most of the times to kill a particular process for e.g. httpd

ps -ef | grep httpd | awk '{print $2}' | xargs sudo kill -9

for find, which has a exec by default. not need to use xargs

You can also remove all .svn files like this.
find . -type d -name .svn -exec rm -rf {} \;

just my 2 paise

- balachandar muruganantham
?????.net - ???? ????? ???????????? ???? - http://ulagam.net
???? ????? ????????? - http://www.balachandar.net/pakkangal
Beyond Work - http://beyondwork.wordpress.com/
"?????????? ?????????? ?????????? ???????? ??????? ?????????? ????. " -
????? ??? : 946

Other related posts: