Bash question
I'm trying to put the date in the name of my file but cant seem to get it I just end up with the word date in the file instead of the date. my script looks like this.
#!/bin/bash x="/var/log/system/" y=date z=${y:11:8} top > $x$y.txt |
I think your variable declaration needs some work.
Here's a snippet from a script I wrote to backup my blog database. First, I created a directory to hold the backup, then I ran mysqldump and dumped the backup into that variable. I am not a coder and I'm sure there was a better way, but this worked. In this case, I wanted the hour and minute in the directory name. Code:
#Set the variable DATE |
Check out the man page for date
Code:
#! /bin/bash Code:
/var/log/system/description-2011:4:11.txt |
So the examples provided by other's are where you need to go, but in relation to your own script lines, the following is your error:
Code:
y=date # this says to set y equal to the string 'date' |
All times are GMT -5. The time now is 12:22 PM. |