trouphaz
New Member
- Sep 22, 2003
- 2,647
So, what is your preferred way of doing repetitive tasks from the shell? There are a bunch of ways to take stdout and run tasks against the output. Do you prefer for loops, while loops, xargs, find with -exec (if you are working on files), what? I personally use for, while and xargs and completely avoid find with -exec.
I use the following a lot:
for X in hostname1 hostname2 ... hostnameN
do
tar cvf - /path/to/files | ssh $X "tar xvf -"
done
vxdisk list | grep error | cut -d"s" -f1 | while read DISK
do
format $DISK <<EOF
l
y
EOF
done
find . -mtime +15 ! -name "*.gz" | xargs -i gzip {}
Do you have preferred ways of doing repetitive tasks?
I use the following a lot:
for X in hostname1 hostname2 ... hostnameN
do
tar cvf - /path/to/files | ssh $X "tar xvf -"
done
vxdisk list | grep error | cut -d"s" -f1 | while read DISK
do
format $DISK <<EOF
l
y
EOF
done
find . -mtime +15 ! -name "*.gz" | xargs -i gzip {}
Do you have preferred ways of doing repetitive tasks?