I'm using Kali linux which is based on Debian and wrote an script to copy some files from where the script is based to a specified directory. But when I execute my script (called CopyFiles.sh
), cp
command works on the root
, not current directory. Here is my script:
#!/bin/bash
cp -f * /var/www/
Also I tried ./*
but same error but if I change directory to my scripts (cd
command) it works fine. I can use following script without problem but I don't want to use any additical commands and want to know why my script doesn't work:
#!/bin/bash
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
cp -f "$SCRIPT_DIR/"* /var/www/
-
?