Can't get BASH script to work, problem with variables

Posted on 2006-04-20
Last Modified: 2011-04-14
My web host only keeps the raw apache log for 1 day.  I'm trying to copy that file over and rename it with the date.  I'm running a BASH script from a cron job.  Here is the script that doesn't work

DATEVAR= date --date=yesterday +%Y-%m-%d
cp /...logs/access_log.1 /.../logs_aggregate/
mv /.../logs_aggregate/access_log.1 /.../$DATEVAR

It copies the log file, but doesn't like the $DATEVAR, anything static works fine.  If I type 'echo $DATEVAR' it prints yesterdays date in the format I want it, '2006-04-19'

So in a nutshell, I want to copy the log file to a new location and rename it with the revious days date.

I just started with bash scripting, so I know I am overlooking something silly, but I've been working on this off and on for over a week.

Question by:Amaddeus
    LVL 84

    Accepted Solution

    DATEVAR=`date --date=yesterday +%Y-%m-%d`

    Author Comment

    I see, the funny quote and no space after the =


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
    The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now