bash script move file to folders based in name

Posted by user289111 on Ask Ubuntu See other posts from Ask Ubuntu or by user289111
Published on 2014-06-06T17:29:50Z Indexed on 2014/06/10 15:41 UTC
Read the original article Hit count: 318

Filed under:
|
|

I hope you can help me...

I made a perl and bash script to make a backup of my firewalls and tranfers via tftp

#!/bin/sh 

 perl /deploy/scripts/backups/10.160.23.1.pl > /dev/null 2>&1
 perl /deploy/scripts/backups/10.160.23.2.pl > /dev/null 2>&1

so this tranfers the file to my tftp directory /tftpboot/

ls -l /tftpboot/
total 532
-rw-rw-rw- 1 tftp tftp 209977 jun  6 14:01 10.160.23.1_20140606.cfg
-rw-rw-rw- 1 tftp tftp 329548 jun  6 14:02 10.160.23.2_20140606.cfg

my questions is how to improve my script to moving this files dynamically to another folder based on the name (in this case on the ip address)

for example: 10.160.23.1_20140606.cfg move to /deploy/backups/10.160.23.1/

is that the answer to this surely was on Google, but wanted to know if there was a particular solution to this request and also learn how to do :)

Thanks!

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about bash