still trying to clean out some of the old data...
Code:
[101635 Live_server_rx30@rx30 ~]$ sh -xvv MOVE
#!/bin/bash
license=`showlic | grep LICENSE | awk '{print $6}'`
showlic | grep LICENSE | awk '{print $6}'
++ showlic
++ grep LICENSE
++ awk '{print $6}'
+ license=101635
DIR=/tmp/DEA-${license}
+ DIR=/tmp/DEA-101635
[ ! -d "${DIR}" ] && mkdir -p ${DIR}
+ '[' '!' -d /tmp/DEA-101635 ']'
[ -f `20[0-9]*.dat` ] && find 20[0-9]*.dat -mtime +15 -exec mv '{}' ${DIR} \;
20[0-9]*.dat
++ 20111122.dat 20111123.dat 20111202.dat 20111212.dat 20111222.dat 20111230.dat 20120109.dat 20120119.dat 20120126.dat 20120202.dat 20120213.dat 20120228.dat 20120306.dat 20120313.dat 20120315.dat 20120330.dat 20120410.dat 20120430.dat 20120510.dat 20120530.dat 20120613.dat 20120620.dat 20120628.dat 20120712.dat 20120725.dat 20120813.dat 20120822.dat 20120828.dat 20120830.dat 20120905.dat
./20111122.dat: line 1: TH*4.1*1122111051*01**20111122*105110*P**\IS*8634523040*CENTRAL: command not found
+ '[' -f ']'
+ find 20111122.dat 20111123.dat 20111202.dat 20111212.dat 20111222.dat 20111230.dat 20120109.dat 20120119.dat 20120126.dat 20120202.dat 20120213.dat 20120228.dat 20120306.dat 20120313.dat 20120315.dat 20120330.dat 20120410.dat 20120430.dat 20120510.dat 20120530.dat 20120613.dat 20120620.dat 20120628.dat 20120712.dat 20120725.dat 20120813.dat 20120822.dat 20120828.dat 20120830.dat 20120905.dat -mtime +15 -exec mv '{}' /tmp/DEA-101635 ';'
exit
+ exit
[101635 Live_server_rx30@rx30 ~]$ cat MOVE
#!/bin/bash
license=`showlic | grep LICENSE | awk '{print $6}'`
DIR=/tmp/DEA-${license}
[ ! -d "${DIR}" ] && mkdir -p ${DIR}
[ -f `20[0-9]*.dat` ] && find 20[0-9]*.dat -mtime +15 -exec mv '{}' ${DIR} \;
exit
[101635 Live_server_rx30@rx30 ~]$ mv /tmp/DEA-101635/*.dat .
[101635 Live_server_rx30@rx30 ~]$ MOVE
./20111122.dat: line 1: TH*4.1*1122111051*01**20111122*105110*P**\IS*8634523040*CENTRAL: command not found
why am i getting those errors?
Code:
-rwxr-xr-x 1 rx30 group 81949 Nov 22 2011 20111122.dat
-rwxr-xr-x 1 rx30 group 79744 Nov 23 2011 20111123.dat
-rwxr-xr-x 1 rx30 group 839 Dec 2 2011 20111202.dat
-rwxr-xr-x 1 rx30 group 1528 Dec 12 2011 20111212.dat
-rwxr-xr-x 1 rx30 group 3376 Dec 22 2011 20111222.dat
-rwxr-xr-x 1 rx30 group 3476 Dec 30 2011 20111230.dat
-rwxr-xr-x 1 rx30 group 840 Jan 9 2012 20120109.dat
-rwxr-xr-x 1 rx30 group 1520 Jan 19 2012 20120119.dat
-rwxr-xr-x 1 rx30 group 2586 Jan 26 2012 20120126.dat
-rwxr-xr-x 1 rx30 group 2868 Feb 2 2012 20120202.dat
the files are there and look as above. the list is WAY to LONG to print em all. point is they are older then 15 days old, except for 1 as it is dated 9/5/2012 would that one give the error?
i have not seen a find -mtime provide that type of error before.
if i understand what i have setup, the
Code:
[ -f `20[0-9]*.dat` ]
is just a check to see if those types of files are in the directory and are regular files.
the && says if the before is true, then perform the latter.
Code:
find 20[0-9]*.dat -mtime +15 -exec mv '{}' ${DIR} \;
that is a rather straight forward simple command. find all of those types of files that are older then 15 days and move them to the proper directory...
What am I missing?