Reputation: 117
i have the script below which is not working .. i could not manage to find the mistakes in it, can anyone help please.
#!/bin/bash
Date=`date +%Y%m%d`
$HomeLogsPath=~/dir1/test/
$LogsBackupDir=~/dir1/backup/$Date/
service httpd stop
if [ -d "$HomeLogsPath" ]; then
cd $HomeLogsPath
pwd
mkdir -p "$LogsBackupDir"
mv * $LogsBackupDir
cd ~
pwd
fi
service httpd start
this is the error that i am getting
./restart.sh: line 4: =~/dir1/test/: No such file or directory
./restart.sh: line 5: =~/dir1/backup/20160506/: No such file or directory
thanks.
Upvotes: 0
Views: 81
Reputation: 2115
HomeLogsPath=~/dir1/test/
LogsBackupDir=~/dir1/backup/$Date/
test -d $HomeLogsPath
if [ "$?" -eq 0 ];then
mv $HomeLogsPath/* $LogsBackupDir
fi
Upvotes: 0
Reputation: 798676
$
should only be used when substituting variables, not when assigning them.
foo=42
Upvotes: 3