4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by thekashyap
-1

Hi,
It is best that you read the Advanced bash scripting guide available at http://tldp.org/LDP/abs/html/
If all you want to do now is create your own command which simply calls another existing linux command, check out "alias"

Votes + Comments
Question is a basic one, far from adv-scripting + the page you gave is just too big for this author to look up.
0

You can also create another directory and add it to your $PATH.

sk@sk:~$ mkdir bin
sk@sk:~$ cd bin
sk@sk:~/bin$ cat >> mycommand << _EOF_
> #!/bin/bash
> echo "hello, world"
> _EOF_
sk@sk:~/bin$ chmod +x mycommand
sk@sk:~/bin$ pwd
/home/wheel/sk/bin
sk@sk:~/bin$ export PATH=${PATH}:/home/wheel/sk/bin
sk@sk:~/bin$ cd ..
sk@sk:~$ mycommand
hello, world
0

There is nothing like "my command". In other words any executable is as good as a command to Linux.
Anything whose x flag is set can be executed as a command on command line by giving full path. It's ur responsibility to ensure the file actually an executable (e.g. shell, perl, py,... script or c/c++ executable...). $ /home/dir/myScript.pl If you do not specify full path to teh command linux looks up all dirs in PATH variable. So if you add "/home/dir" to PATH, you don't have to specify full path on cmd line

$ echo $PATH
.:/home/dir:/bin
$ myScript.pl

See shell variables section in man page of your shell.

Edited by thekashyap: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.