From: Dale <rdalek1967@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Renaming files with those pesky picture type characters.
Date: Wed, 30 Oct 2024 12:25:46 -0500 [thread overview]
Message-ID: <f1007381-e2e8-6fd3-1979-951fd1cbeeae@gmail.com> (raw)
In-Reply-To: <76de2cf9-c045-45c3-b4ed-9c549beadfa1@gentoo.org>
Eli Schwartz wrote:
> 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 "--".
>
Oh, that's good. I think. :/
That link has a lot of info. That could take a while to digest. I did
find the -- part tho.
> 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.
>
Well, I did try single quotes, double quotes and other stuff I'd seen
before but none worked. Eventually, I ran out of ideas. I've never ran
into anything that required more than that either. So, I brought up my
search engine and then it hit me, what do I search for???? I went
outside, watered my kale and collard green seeds, and did some
thinking. I couldn't even think of what to search for to find a
answer. Given it didn't work in a GUI or command line, I was kinda
lost. I did know tho, there was a way. There had to be. I decided to
just ask.
Now I have lots more info in case I run up on this again. I also added
a entry to my tips cheat sheet. Oh, I can also run Frank's checksum
tool on that directory. I store that data for someone else. It should
ever change. That's the reason for the checksum tool for it.
Thanks much.
Dale
:-) :-)
P. S. My mustard and turnip greens are popping up. That will make
family, friends and neighbors happy. I had to reseed my collard and
kale. May have put first planting to deep.
next prev parent reply other threads:[~2024-10-30 17:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 15:18 [gentoo-user] Renaming files with those pesky picture type characters Dale
2024-10-29 15:47 ` Michael
2024-10-29 16:18 ` Dale
2024-10-29 16:40 ` Michael
2024-10-29 18:05 ` Dale
2024-10-30 3:05 ` Eli Schwartz
2024-10-30 17:25 ` Dale [this message]
2024-11-01 2:25 ` Andrew Lowe
2024-11-01 14:16 ` Jack Ostroff
2024-11-01 16:02 ` Dale
2024-11-03 23:52 ` Wol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f1007381-e2e8-6fd3-1979-951fd1cbeeae@gmail.com \
--to=rdalek1967@gmail.com \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox