Showing posts with label xargs. Show all posts
Showing posts with label xargs. Show all posts

Saturday, November 7, 2015

Tuesday, June 12, 2012

grab that oneliner for sledgehammering with xargs and remote execute

Finally found the command on one node.... now how to grab that and execute it on milions of hosts (with a passwordless setup)
   66  ps auxww| grep Server | grep -v grep | awk '{ print $2 }' | xargs -i{} -t /usr/sbin/lsof -p {}  | grep wls10
Here you go
   77  history | grep Server | grep -v history | cut -c8- | grep wls10 | head -1 > ~/wls10.txt
   78  cat list | xargs -i{} -t ssh {} "$(<wls10.txt)"

xargs and using the stdin reference more than once

Multiple tar extractions in different directories based on the tar name.
computer:x usr$ ls -rtl
total 426552
-rw-r--r--  1 usr  usr  73451520 Jun 12 17:59 l01-2.tar
-rw-r--r--  1 usr  usr  72622080 Jun 12 17:59 l02-2.tar
-rw-r--r--  1 usr  usr  72284160 Jun 12 17:59 l03-2.tar
The only way I was able to do it is to push it into a small script, louzy.... I'll keep you posted on the alternatives.
computer:x usr$ cat test.txt 
mkdir $1 
cd $1 && tar xfv ../$1.tar && cd ..
computer:x usr$ ls -1 *.tar | sed 's/\.tar//' | xargs -I{} -t /bin/bash test.txt {}