Comment on mv *.jpg is complete bullshit.

GenderNeutralBro@lemmy.sdf.org ⁨8⁩ ⁨months⁩ ago

This is not standard behavior. Got links to StackOverflow?

This works just fine in bash and zsh:

encoded_funky_name=IUAjJCVeJiooKVtde30nIjo7IGxzOyAmYW1wOyA8Plx8YH5gJChscykke1BBVEh9ISF8fCYmLmpwZw==
# decodes to: !@#$%^&*()[]{}'":; ls; &amp; <>\|`~`$(ls)${PATH}!!||&&.jpg

mkdir temp
cd temp
mkdir temp2

touch $(echo "${encoded_funky_name}" | base64 -d)

mv ./*.jpg temp2
ls -lR

mv temp2/*.jpg .
ls -lR

Note that it is recommended to use “./” before a raw * in globs to avoid filenames beginning with “-” being interpreted by the command as special arguments (this is not necessary in the above example, but it is a good habit). See dwheeler.com/essays/filenames-in-shell.html#globb… for more info. e.g.:

touch ./-laR 

# Bad ls command:
ls *

# Good ls command:
ls ./*

having it put each name in quotes should be fucking trivial

This is effectively what happens, except that it’s actually more robust than that, since it also accounts for names with quotes and other special characters. Glob expansion does NOT output file names into the shell; it passes them as arguments to the command with no further shell processing. Arguments can contain any special characters.

Not sure why you’re seeing this behavior. Are you doing something with these file names before passing them to mv? Storing them in variables? Saving them to files?

source
Sort:hotnewtop