0

If I run this

#!/bin/bash
clear
hadoop fs -ls

clear is not executed. Instead I get

: command not foundar
Found 2 items
list of items

If I add ";" after clear it gets executed, but I still get

: command not found
Found 2 items
list of items

Why is that?

gjin
  • 860
  • 1
  • 14
  • 28
  • 2
    Is that really `command not found` as in the title, or is it `command not foundar` as in the quoted output. The fact that `clear` ends in `ar` is suspicious. – JimD. Jan 19 '17 at 09:33
  • @Jim It's command not foundar. Why is that suspicious? – gjin Jan 19 '17 at 09:36
  • How do you run this script? – Avihoo Mamka Jan 19 '17 at 09:36
  • @Avihoo sh scr.sh – gjin Jan 19 '17 at 09:37
  • I suspect that is your problem.. you run it through `sh` shell, but your shebang line declares `bash`. Try run: `bash scr.sh` – Avihoo Mamka Jan 19 '17 at 09:38
  • @Avihoo get **: command not foundar** without a ";" and **: command not found** with ";" too – gjin Jan 19 '17 at 09:42
  • Do you run this script under Linux or Windows? – Avihoo Mamka Jan 19 '17 at 10:52
  • @Avi I am sitting on a windows machine connected to a linux server through putty =P So I am running it on linux, I guess. I checked the link you provided and you were right. The problem is the same. – gjin Jan 19 '17 at 11:20
  • So you need to use `dos2unix scr.sh` to remove all the line ends that fits to windows but not to linux. – Avihoo Mamka Jan 19 '17 at 11:21
  • @Avi I thought so too) But `dos2unix scr.sh bash: dos2unix: command not found` – gjin Jan 19 '17 at 11:24
  • @EugeneCuz Just because you do not *have* that command doesn't mean you don' t need to do what it does. See the [tag wiki](http://stackoverflow.com/tags/bash/info) for more suggestions. – chepner Jan 19 '17 at 12:29
  • @che I solved my problem this way `awk '{ sub("\r$", ""); print }' winfile.sh > unixfile.sh` – gjin Jan 19 '17 at 12:42
  • When weird stuff like this happens, my goto is `xxd scr.sh` to check if there's something unusual going on – Jeffrey Cash Jan 20 '17 at 01:35

0 Answers0