0

I'm scripting a file which will change the permissions of a file once it is run. I keep getting these errors on the Cygwin terminal:

$ chmx.bash
/home/user/scripts/chmx.bash: line 2: $'\r': command not found
/home/user/scripts/chmx.bash: line 4: $'\r': command not found
chmod: cannot access ‘chmxtext.txt\r\r’: No such file or directory

Here's my script:

#!/bin/bash

fileName="chmxtext.txt"
chmod a+rwx "$fileName"
Anthony Geoghegan
  • 11,533
  • 5
  • 49
  • 56
  • 6
    Sounds like you have some windows-style newline characters. Check the [info on this page](http://stackoverflow.com/tags/bash/info) on how to remove them – arco444 Jun 29 '15 at 12:43
  • @arco444 I upvoted your comment but it should really be posted as an answer so that Matthew has the opportunity to accept it. – Anthony Geoghegan Jun 29 '15 at 13:23
  • @AnthonyGeoghegan I disagree - Really the question should be closed as off topic due to typographical error or as a duplicate as I'm sure there must be other posts that already contain the contents of the comment as an answer. – arco444 Jun 29 '15 at 13:29
  • possible duplicate of ['\r': command not found - .bashrc / .bash\_profile](http://stackoverflow.com/questions/11616835/r-command-not-found-bashrc-bash-profile) – Anthony Geoghegan Jun 29 '15 at 13:41

0 Answers0