Skip to main content
Add use another language
Source Link
mmmmmm
  • 31k
  • 18
  • 94
  • 158

From the man page for mv, the first (and possibly second) argument on the command line, if it begins with a -, is an option and not a file. Only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name—it will confuse other command line programs—given that prepending - is a workaround for something else I would just not use that character.

If this is not an option, you can rewrite the mv commands like this

mv ./"$f" "${DIRNAME}/${FILENAME:2}"

or (a bit more generic because it then also works for absolute paths)

mv -- "$f" "${DIRNAME}/${FILENAME:2}"

Another option (and is what I would do for any bash script longer than a few lines) is write in a scripting language like perl or python - in this case they solve the problem by their move functions not passing the filenames to mv

From the man page for mv, the first (and possibly second) argument on the command line, if it begins with a -, is an option and not a file. Only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name—it will confuse other command line programs—given that prepending - is a workaround for something else I would just not use that character.

If this is not an option, you can rewrite the mv commands like this

mv ./"$f" "${DIRNAME}/${FILENAME:2}"

or (a bit more generic because it then also works for absolute paths)

mv -- "$f" "${DIRNAME}/${FILENAME:2}"

From the man page for mv, the first (and possibly second) argument on the command line, if it begins with a -, is an option and not a file. Only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name—it will confuse other command line programs—given that prepending - is a workaround for something else I would just not use that character.

If this is not an option, you can rewrite the mv commands like this

mv ./"$f" "${DIRNAME}/${FILENAME:2}"

or (a bit more generic because it then also works for absolute paths)

mv -- "$f" "${DIRNAME}/${FILENAME:2}"

Another option (and is what I would do for any bash script longer than a few lines) is write in a scripting language like perl or python - in this case they solve the problem by their move functions not passing the filenames to mv

added 239 characters in body
Source Link
nohillside
  • 104.5k
  • 42
  • 222
  • 275

From the man page for mv, the first (and possibly second) argument on the command line, if it begins with a -, is an option and not a file. Only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name—it will confuse other command line programs—given that prepending - is a workaround for something else I would just not use that character.

If this is not an option, you can rewrite the mv commands like this

mv ./"$f" "${DIRNAME}/${FILENAME:2}"

or (a bit more generic because it then also works for absolute paths)

mv -- "$f" "${DIRNAME}/${FILENAME:2}"

From the man page for mv, the first (and possibly second) argument on the command line, if it begins with a -, is an option and not a file. Only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name—it will confuse other command line programs—given that prepending - is a workaround for something else I would just not use that character.

From the man page for mv, the first (and possibly second) argument on the command line, if it begins with a -, is an option and not a file. Only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name—it will confuse other command line programs—given that prepending - is a workaround for something else I would just not use that character.

If this is not an option, you can rewrite the mv commands like this

mv ./"$f" "${DIRNAME}/${FILENAME:2}"

or (a bit more generic because it then also works for absolute paths)

mv -- "$f" "${DIRNAME}/${FILENAME:2}"

Fri=omFrom the manageman page for mvmv, the first and(and possibly second arguments) argument on commandthe command line, if it begins with a --, is an option and not a file and only -f | -i |. Only -n-f | -i | -n are allowed options.

Simplest way is not to use -- in a file name - itname—it will confuse other command line programs - givenprograms—given that prepending -- is a workaround for something else I would just not use that character.

Fri=om the manage for mv the first and possibly second arguments on command line if it begins with a - is an option and not a file and only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name - it will confuse other command line programs - given that prepending - is a workaround for something else I would just not use that character

From the man page for mv, the first (and possibly second) argument on the command line, if it begins with a -, is an option and not a file. Only -f | -i | -n are allowed options.

Simplest way is not to use - in a file name—it will confuse other command line programs—given that prepending - is a workaround for something else I would just not use that character.

Source Link
mmmmmm
  • 31k
  • 18
  • 94
  • 158
Loading