-1

I want to write a bash script to move every file in one subfolder into another subfolder of the same name in a different folder. I tried the following script, which I called merge.bash:

file_path=/home/path/folder
mv subfolder/* "$file_path"/subfolder

When I ran this with:

bash merge.bash

It returned the error:

mv: target '/home/path/subfolder'$'\r' is not a directory

Why has it added '$'\r ?

user8144422
  • 101
  • 1
  • 8

1 Answers1

0

Using notepad++ for example, and look at the end of each line, there is a setting to change to Windows CRLF, which stands for Carriage Return Line Feed, for Linux it is LF, which stands for Line Feed, and for Mac it is CR, which stands for Carriage Return.

Shaqil Ismail
  • 1,794
  • 1
  • 4
  • 5
  • The code was written in notepad. I removed the carriage return with sed -i 's/\r//g' merge.bash and it works now. Thanks a lot! – user8144422 May 25 '21 at 11:13