0

I am trying to execute a very simple shell script that removes a file if it exists, and then copies a file from hdfs to the local system.

#!/bin/bash
rm -f /local/file
hdfs dfs -get /path/to/hdfs /local/file

Both commands work individually in the terminal, but fail when run as a script. Running

rm /local/file

fails with rm: cannot remove ‘/local/file\r’: No such file or directory

hdfs dfs -get /path/to/hdfs

fails with get: unexpected URISyntaxException

What am I doing wrong here?

mkh
  • 85
  • 3
  • 1
    That error message suggests your script file is in DOS/Windows format; see [Are shell scripts sensitive to encoding and line endings?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – Gordon Davisson Oct 08 '20 at 20:24
  • You're right, dos2unix fixed it. Thank you! – mkh Oct 08 '20 at 21:56

0 Answers0