You are not logged in.
So I have this:
BKP_WHERE=/home/phil/backup
BKP_FILE=`date +%e_%m_%y`_backup.tar.gz
echo $BKP_WHERE/$BKP_FILE
and that returns: /home/phil/backup/ 8_05_09_backup.tar.gz
Notice the space between those two variables. Is there any way to fix this?
Offline
Searching for bash trim in google returned this page, http://stackoverflow.com/questions/3697 … h-variable which seems to be mostly useless apart from maybe this solution:
var=`hg st -R "$path" | sed -e 's/ *$//'`
So I suppose you could write:
BKP_FILE="`date +%e_%m_%y | sed -e 's/ *$//'`_backup.tar.gz"
Or something to that effect. Good luck!
Offline
Searching for bash trim in google returned this page, http://stackoverflow.com/questions/3697 … h-variable which seems to be mostly useless apart from maybe this solution:
var=`hg st -R "$path" | sed -e 's/ *$//'`
So I suppose you could write:
BKP_FILE="`date +%e_%m_%y | sed -e 's/ *$//'`_backup.tar.gz"
Or something to that effect. Good luck!
The BKP_FILE variable works correctly, it is just when I combine it with the other there is a space between them.
Offline
date's manpage describes the %e option as day of month space padded. That is where the space is coming from. It doesn't appear when the output is to a terminal though. Use %d instead:
BKP_WHERE=/home/phil/backup
BKP_FILE=`date +%d_%m_%y`_backup.tar.gz
echo $BKP_WHERE/$BKP_FILE
Edit: Ah it does appear in a terminal. I just hadn't noticed it.
Last edited by mikesd (2009-05-09 04:38:52)
Offline
date's manpage describes the %e option as day of month space padded. That is where the space is coming from. It doesn't appear when the output is to a terminal though. Use %d instead[.]
date +%-e_%m_%y should also work (ie, put a 'minus' after '%'.
Offline
mikesd wrote:date's manpage describes the %e option as day of month space padded. That is where the space is coming from. It doesn't appear when the output is to a terminal though. Use %d instead[.]
date +%-e_%m_%y should also work (ie, put a 'minus' after '%'.
worked great! Thanks!
Offline