I have two similar scripts with different names. One works fine but other throws error. Can anyone please tell me what is the issue?
This is my test.sh scripts which works fine
[nnice@myhost Scripts]$ cat test.sh
#!/bin/bash
function fun {
echo "`hostname`"
}
fun
[nnice@myhost Scripts]$ ./test.sh
myhost.fedora
Here is my another script demo.sh but it throws error
[nnice@myhost Scripts]$ cat demo.sh
#!/bin/bash
function fun {
echo "`hostname`"
}
fun
[nnice@myhost Scripts]$ ./demo.sh
bash: ./demo.sh: cannot execute: required file not found
Both scripts having the same permissions
[nnice@myhost Scripts]$ ll test.sh
-rwxr-xr-x. 1 nnice nnice 65 Oct 21 10:47 test.sh
[nnice@myhost Scripts]$ ll demo.sh
-rwxr-xr-x. 1 nnice nnice 58 Oct 21 10:46 demo.sh
... `command` ...
is deprecated. Use the newer easier to use"$(command)"
(but yes this simple use with echo is hoop jumping). Use of.sh
at the end of file names is not Unix. And it violates the principle of abstraction, as it leaks implementation detail. Just name them by what they do, not how they do it.hostname
command directly rather than via a nonsensical script with a function.deprecate
: express disapproval of. I disapprove. You say should be avoided. Thus deprecated. As for up to the user. I agree, it is the same for drug use. And the best abstraction is no abstraction (it depends). However I assume the examples were minimum non-working examples.