Vagho Vagho - 1 year ago 108
Bash Question

bash script mkdir mv issue

i have the script below which is not working .. i could not manage to find the mistakes in it, can anyone help please.


Date=`date +%Y%m%d`

service httpd stop

if [ -d "$HomeLogsPath" ]; then
cd $HomeLogsPath
mkdir -p "$LogsBackupDir"
mv * $LogsBackupDir
cd ~

service httpd start

this is the error that i am getting

./ line 4: =~/dir1/test/: No such file or directory
./ line 5: =~/dir1/backup/20160506/: No such file or directory


Answer Source

$ should only be used when substituting variables, not when assigning them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download