0

I wrote the following script; it's modified for simplicity and privacy reasons:

FILES_ROOT='/data/FILES'

BACK_B2B_RETURNS_S="$FILES_ROOT"'/wms-m-company/w2z/b2breturns/backup'
BACK_B2B_RETURNS_D="$FILES_ROOT"'/wms-d-company/w-to-z/backup/m-company/b2b-delivery-confirmations'
find "$BACK_B2B_RETURNS_S" -maxdepth 1 -type f -exec mv {} "$BACK_B2B_RETURNS_D" \;

LOG_B2B_RETURNS_S="$FILES_ROOT"'/wms-m-company/w2z/b2breturns/log'
LOG_B2B_RETURNS_D="$FILES_ROOT"'/wms-d-company/w-to-z/backup/m-company/b2b-delivery-confirmations/log'
find "$LOG_B2B_RETURNS_S" -maxdepth 1 -type f -exec mv {} "$LOG_B2B_RETURNS_D" \;

Executing the script gives me this error:

-bash: $'\r': command not found
-bash: $'\r': command not found
find: missing argument to `-exec'
Try 'find --help' for more information.
-bash: $'\r': command not found
find: missing argument to `-exec'
Try 'find --help' for more information.

I don't understand why. Normally, I would debug using the terminal but this is not an option since it works when I copy/paste/execute this line by line in the terminal.

Is there anyone who understands what's wrong with this script?

MaestroMaus
  • 115
  • 4

1 Answers1

2

You have MSWin line ends in the script source. Use dos2unix or fromdos to fix them.

choroba
  • 374
  • 1
  • 7