Im trying to do a full back up and copy over all files from one directory into another directory
#!/bin/bash
#getting files from this directory
PROJECTDIRECTORY=/../../Project3
#Copied to this directory
FILEBACKUPLOCATION= /../.../FMonday
for FILENAME in $PROJECTDIRECTORY/*
do
cp $FILENAME $FILEBACKUPLOCATION
done
But I keep getting this error
./fullbackup: line 6: /../../FMonday: Is a directory
cp: missing destination file operand after
Variable assignments in bash scripts require no space between the variable name and value or (unless quoted) within the value. Since a space was present in the line FILEBACKUPLOCATION= /../.../FMonday
, it attempted to execute /../.../FMonday
as a command (which caused the first error) with FILEBACKUPLOCATION
assigned to an empty string. The variable was then not assigned when the other command further down tried to use it (accounting for the second error).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With