I have a file named scanner
:
#!/bin/sh
python lexAnalyser.py $*
I want it to run as $ scanner test.txt
instead of $ ./scanner test.txt
.
Thanks for any help you can give. I am just starting to use Linux and am trying to get my boots on.
You can do:
$ ./scanner test.txt
$ PATH=$PATH:$PWD
$ scanner test.txt
but it's preferable to have $HOME/bin
in your path and your scripts there.
$HOME/bin
. (And if you don't want to move the script to there, you can always symlink it. I don't know why you'd want that, but it's an option.)
You can put the file in one of the paths specified by $PATH
, for example, you can copy it to /usr/bin
and then the shell will automatically recognize it by name without typing its full path.
scanner
is in to your pathscanner
to a directory that's already in your path.scanner
to the full path of where the file is.
./
tells shell that the preceeding file is an executable scriptset PATH= .:$PATH
(maybe to muchcsh
?).bashrc
, putexport PATH=$PATH:.
./
tells the shell that it's in the current directory.