Sir Robert Sir Robert - 1 year ago 50
Bash Question

Bash shell complains of invalid options I didn't use ... only on *.mp4 file extensions

I have a bunch of MP4 files that look like this:

-rw-rw-r-- 1 116M Apr 19 06:08 lULIqx9Akn4.mp4

These are youtube videos. When I try to do anything with all of them, I get a weird error. Every command I try says that I'm using invalid options (that I am not using). Here are some examples.

$ ls *.mp4
/bin/ls: invalid option -- '7'
Try '/bin/ls --help' for more information.
$ mv *.mp4 videos/
mv: invalid option -- 'L'
Try 'mv --help' for more information.
$ cp *.mp4 videos/.
cp: invalid option -- '7'
Try 'cp --help' for more information.

It doesn't do the same thing with a different extension (*.mp3, *.txt, *.sh).

What's going on? How do I fix this?

I used this as a cheap workaround,

find . -name "*.mp4" -exec mv {} videos/. \;

but I want to understand what's happening, not just get the job done.

cxw cxw
Answer Source

One of your filenames starts with a hyphen, e.g,. -7 or -L. Try ls -- *.mp4 or cp -- *.mp4 videos. Also, allow me to suggest UNIX and Linux Stack Exchange for shell questions :) .