Score:0

$'\r': command not found error when executing find in a bash script

cn flag

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?

in flag
You have MSWin line ends in the script source. Use `dos2unix` or `fromdos` to fix them.
MaestroMaus avatar
cn flag
Please write this as a solution; so I can approve this as the answer.
Score:2
in flag

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

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.