案例一:删目录

image.png

  1. ll | grep '^d' | awk '{print $9}' | xargs -n 1 echo 'rm -rf'

image.png

执行

  1. ll | grep '^d' | awk '{print $9}' | xargs -n 1 echo 'rm -rf' | sh

image.png

案例二:杀进程

  1. ps -ef | grep sleep.sh | grep -v grep | awk '{print $2}' | xargs -n 1 echo 'kill -9'

image.png

执行

  1. ps -ef | grep sleep.sh | grep -v grep | awk '{print $2}' | xargs -n 1 echo 'kill -9' | sh

image.png