Bash script: command not found

bash version 4.3.48(1)-release (i686-pc-linux-gnu)
ubuntu MATE 16.04 LTS

why will this not work?

#1/bin/bash
history -c && history -w
exit

vim’d the script as ch.sh (for ‘clear history’)
placed in pat ~/bin/ch.sh
chmod -x ch.sh

still get command not found

Hi @b4udv8, A few possibilities.

  1. chmod **+**x (you have -x). Most likely.

  2. 1/bin/bash may be a typo and formatting here can hinder but should be…

#!/bin/bash
  1. Be sure and login with ~/bin so it gets in $PATH. Newly created it will not be in $PATH until logout/login or reboot.

HTH

Are you trying to run the command as ch.sh or just ch (which won’t work)? (This was an early error I made.)

I tried first as just ch with command not found. Then tried it as ch.sh with the same results.

As far as $PATH, it lists /home/b4udv8/bin which I also moved ch.sh shell
to, but same results.

Please see - https://en.wikipedia.org/wiki/Shebang_(Unix)

Did you correct the typo in your command? Just curious…

Yes I fixed the typo (it was actually typed wrong in my post).
Now when I execute ‘ch’ it just returns to the command prompt.