Jesse_b already answered the question, but I think it's worth to address some potential misconceptions.
The shell has characters that have special meaning under some specific conditions. For example: |
is used in pipelines, >
in redirections, \
to escape characters, etc. Those characters are not interpreted literally by the shell, so that's why when you do echo foo>bar
, foo>bar
won't be printed to your terminal, but foo
will be redirected to the bar
file.
Fortunately, the shell also has a mechanism which makes these characters to lose their special meaning: quoting. In POSIX shells, there are 3 quoting mechanisms:
- Backslash
\
: preserves the literal value of the following character, with the exception of a <newline>
.
- Double-quotes
"..."
: preserves the literal value of all characters within the double-quotes, with the exception of the characters `
, $
, and \
.
- Single-quotes
'...'
: preserves the literal value of each character within the single-quotes, no exceptions.
So, following the previous example, if we wanted to print foo>bar
literally, we could have done:
echo foo\>bar
echo "foo>bar"
echo 'foo>bar'
The asterisk *
is one of those special characters, it is part of the pattern matching notation and is used for filename expansion. In other words, commands such as echo *.txt
will replace the pattern with the files that the pattern matches.
In your case, cron_daily/wp_cli.sh*
only matches cron_daily/wp_cli.sh
, so mv
sees 2 identical arguments and complains about it. That's fine because there's no cron_daily/wp_cli.sh*
file. But if you had had an actual cron_daily/wp_cli.sh*
file and more files that could be matched by the pattern, mv
would have fail.
Consider the following scenario:
$ ls -l
total 0
-rw-rw-r-- 1 user group 0 jul 14 12:00 file*
-rw-rw-r-- 1 user group 0 jul 14 12:00 file1
-rw-rw-r-- 1 user group 0 jul 14 12:00 file2
-rw-rw-r-- 1 user group 0 jul 14 12:00 file3
If I try to rename file*
without using quotes:
$ mv file* new_file
mv: target 'new_file' is not a directory
That's because these are the arguments that mv
receives, thus new_file
is expected to be a directory:
$ printf '[%s]\n' file* new_file
[file*]
[file1]
[file2]
[file3]
[new_file]
To successfully rename file*
, I need to quote that argument:
$ mv 'file*' new_file
$ ls -l
total 0
-rw-rw-r-- 1 user group 0 jul 14 12:00 file1
-rw-rw-r-- 1 user group 0 jul 14 12:00 file2
-rw-rw-r-- 1 user group 0 jul 14 12:00 file3
-rw-rw-r-- 1 user group 0 jul 14 12:00 new_file
/
) or null byte. You can make files with asterisks no-prob by quoting the asterisk or escaping it like thistouch wp_cli.sh\*
.