I want to backup a file periodically using the 7z command.
Below is testscript.sh:
7za a $DESTDIR$FILENAME $SRCDIR
I suspect there is a copy/paste error with your
SRCDIR variable, as the
WARNING: No more files output indicates that it is trying to scan a directory with no name. Simply specifying the wrong variable name (and thus no directory) would cause it to include the files from the current directory, so it's probably something more sinister like an invalid character in your script somewhere. Have you tried looking at the script with
hexdump -C to ensure there's no weird stray characters anywhere?
If I use a source directory named
^M is literally the carriage return character (inserted in vim with
^V ^M), I get the same result as shown in your screenshot.
Here's an excerpt from the bash tag wiki:
Check whether your script or data has DOS style end-of-line characters
cat -v yourfile or
echo "$yourvariable" | cat -v .
DOS carriage returns will show up as
^M after each line.
If you find them, delete them using
tr -d '\r'