I have files in `/root/test/access.log.1` to `999` and `/root/test/error.log.1` to `999`. 

I would like to rename `access.log.1` to `access.log.2` and move to `/var/log/archives/`, and same way `error.log.1` to `error.log.2`. 

I tried something like below

```
#!/bin/bash
NEWFILE=`ls -ltr |grep error |tail -2 | head -1 |awk '{print $9}'`
for i in `ls -ltr |grep error |tail -1`;
do
    mv "$i" /var/log/archives/"$NEWFILE"
done

```