On 10/29/24 2:05 PM, Dale wrote: > I saw that but never understood what it did. I thought it was > something that worked just with revdep-rebuild or something. So it > is a bash thing. Interesting. That could open a can of worms. It's not a bash thing. It is a software thing. It is mandated by the POSIX standard: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html That means, as a general rule of thumb, all Unix commands required to exist everywhere, *have to* support the usage of "--" in this manner. And since it is a sensible thing to do, most programs, even not POSIX programs, heed the wise advice of POSIX and support "--". On 10/29/24 11:18 AM, Dale wrote: > Howdy, > > I downloaded some files. I have a few that have some weird names. > Some have those picture type characters. Some start with a dash, > "-". In some cases I can use wild cards to change them. Frank gave > me some ideas on that off list, while discussing his nifty checksum > tool. Anyway, I ran up on a few that start with a dash, "-", and I > can't find a way around that. The mv command thinks it is me trying > to include a option. It spits out something like this. > > > mv: unrecognized option '---ne.avi' > > > Some of the other characters I run into look like this. > > > ���� > > > Those I can usually get around with wildcards. I have not found a > way to get around the ones with the dash in front tho. I tried a > single quote, double quote etc but still no worky. Also, tab > completion doesn't help either. I feel like, in combination with the bash comment above, this speaks to a general misunderstanding of how quotes, dashes, wildcards, etc work. So I would like to clarify something here. If you try to $ mv ---ne.avi new-filename.avi and it doesn't work, and you try $ mv "---ne.avi" new-filename.avi Or more generally, if you have a filename named this is a weird filename.avi You have various options for writing a "mv" command for it in a bash shell, but that's not actually what the "mv" program sees. Example: $ mv "this is a weird filename.avi" better.avi is actually executed as an operating system array: {"mv", "this is a weird filename.avi", "better.avi"} You can also do: $ mv this\ is\ a\ weird\ filename.avi better.avi Still, bash tries to figure out how to convert it into an operating system array, and gets: {"mv", "this is a weird filename.avi", "better.avi"} You can even do: $ mv *weird*filename.avi" better.avi Still, bash tries to figure out how to convert it into an operating system array, and gets: {"mv", "this is a weird filename.avi", "better.avi"} It's always converted to that array. But, $ mv this is a weird filename.avi better.avi becomes this array: {"mv", "this", "is", "a", "weird", "filename.avi", "better.avi"} and obviously that is an entirely different command because the array is different (each part is a different filename, as far as "mv" knows.) Same with stuff that begins with a dash. $ mv "---ne.avi" new-filename.avi $ mv '---ne.avi' new-filename.avi $ mv ---ne.avi new-filename.avi $ mv *-ne.avi new-filename.avi $ mv \-\-\-ne.avi new-filename.avi all become {"mv", "---ne.avi", "new-filename.avi"} Which does not help you because the array values that the "mv" command sees are still starting with a single dash. From bash (and from bash tab completion) all you can do is update bash text lines which then get translated into arrays so you can execute the array as a program. Quoting and wildcards do NOT affect how "mv" works. All that quoting and wildcards do is affect whether space characters are interpreted as part of the filename or as the separator between different array items. The "mv" program is responsible for knowing what a dash is or does. It tries first to treat it as an option, and that's why "--" works -- because it tells "mv" itself to stop treating it as an option, and to treat it as a filename instead. That is also why "./---new.avi" works. All filenames (except those starting with / such as /home or /usr, of course) can have an added directory at the beginning, and the obvious one is ./ but you could also use "$PWD/---new.avi" if you wanted. Since it doesn't start with a dash, it can't be an option. -- Eli Schwartz