[Linux-disciples] write to file from shell script

Dylan Paul Thurston dpt at math.cornell.edu
Tue Nov 15 23:04:06 EST 2011


The problem in the initial script, this one:

On Tue, Nov 15, 2011 at 09:28:09PM -0500, Jamie Forrest wrote:
> #!/bin/bash
> 
> NOW=`date +%F`
> gondor sqldump primary > $NOW_dump.sql

is that it's looking for a variable $NOW_dump, which doesn't exist.
It probably created a file '.sql' as a result.  You can fix it like
you did later, or by adding braces:

#!/bin/bash

NOW=`date +%F`
gondor sqldump primary > ${NOW}_dump.sql

--Dylan


More information about the Linux-disciples mailing list