I run this bash script in order to put all the files with the following format dated today in the same folder. for example here I want 2012-12-17_083213
to be my folder and then inside it I have the .log
and .log_stats
and etc with this name inside it?
But I am not able to get the script working. For example, if I try everything up until dir=$(echo $i | awk '{split($1,a,"_"); print a[1]}');
And then to test it, I did echo $dir, and that displays the following:
fwui.log
I searched and understood its about locks in the db but how to solve it?
This is the script:
#!/bin/bash
tosend=""
for i in *.log; do
dir=$(echo $i | awk '{split($1,a,"_"); print a[1]}');
if [ ! -d $dir ]; then
mkdir $dir;
fi;
cp $i $dir;
tosend="$tosend\n$dir"
done
for i in $(echo -e $tosend | uniq);do
echo Compressing $i
tar -zcvf $i.tar.gz $i
scp $i.tar.gz user@server
done
and this is the file formats:
2012-12-17_083213_1.log
2012-12-17_083213_1.log_stats
2012-12-17_083213_1.logaccount_ptr
2012-12-17_083213_1.loginitial_ptr
2012-12-17_083213_1.logptr
2012-12-17_093049_2.log
2012-12-17_093049_2.log_stats
2012-12-17_093049_2.logaccount_ptr
2012-12-17_093049_2.loginitial_ptr
2012-12-17_093049_2.logptr
user@server
in your code, right? Because if there's no:
(as inuser@server:
for the home ofuser
onserver
) in the target spec ofscp
, it works likecp
, only copying all your files to the fileuser@server
.