shell中seq运用


范例:


将/bugzilla/group.00....group.99下的超过3年的数据mv到/history/Bugzilla/group.00...group.99下


seq -w 00 99 (-w表示在前面补0,以使宽度相同)


#!/bin/bash


for inum in `seq -w 00 99`

do

SSDIR=/bugzilla/group.$inum

DDDIR=/history/Bugzilla/group.$inum

cd ${SSDIR}

for Job in $(ls)

do

if [ $(( (`date +%s` - `stat -L --format %Y $Job`) > (3*365*24*60*60) )) = 1 ];then

/bin/mv $SSDIR/$Job $DDDIR/

fi

done

done