Why repeat the same command 10 times when you can put it in a loop??
Put “for” to use… Here are a few examples:
* Kill off all processes for a specific application..
for PID in `ps -ef | grep app_name | grep -v grep | awk '{print $2}'`
do
kill -9 ${PID}
done
* Lock out out all the users in a specific group…
GROUP=`grep group_id /etc/group | awk -F":" '{print $3}'`
for USER in `grep ":${GROUP}:" /etc/passwd | awk -F":" '{print $1}'`
do
passwd -l ${USER}
done
* Untar a bunch of files…
gunzip *.tar.gz
for TARBALL in `ls -1 *.tar`
do
tar xf ${TARBALL}
done
I could go on…