#!/bin/bash
#check dns backups
Code:
#!/bin/bash
#check dns backups
gdate=`date | awk '{print $2,$3;}'`
tmp="/apps/backups/complete"
cd /apps/backups/dnsone
for dir in `ls /apps/backups/dnsone | grep 1`
do
cd /apps/backups/dnsone/$dir
for file in `ls -l | grep $gdate | awk '{print $9;}'`
do
size=`ls -l | grep $file | awk '{print $5;}'`
date=`ls -l | grep $file | awk '{print $6,$7;}'`
echo "$file was backed up to /apps/backups/dnsone$dir/$file on $date. The file size is $size" >> $tmp
done
done
Code:
# cd /apps/backups/dnsone
# ls | grep 1
10-10-1-50
10-128-133-14
10-128-5-14
10-128-5-42
10-128-5-43
10-4-0-149
10-5-0-1
When I run this, I get
Code:
# ./dns.sh
grep: can't open 13
grep: can't open 13
grep: can't open 13
grep: can't open 13
grep: can't open 13
grep: can't open 13
grep: can't open 13
I know that it is trying to run
when I want it to run
I know it works with the quotes because I have substituted them for the variable.
I tried
Code:
gdate=\"`date | awk '{print $2,$3;}'`\"
, and when I echo $gdate it gives me "May 13", so I thought that should work, but it gives me
Code:
grep: can't open 13"
grep: can't open 13"
grep: can't open 13"
grep: can't open 13"
grep: can't open 13"
grep: can't open 13"
grep: can't open 13"