Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file named scanner:

python $*

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.

share|improve this question

migrated from Oct 17 '12 at 8:22

This question came from our site for professional and enthusiast programmers.

Why would you want to do that? ./ tells shell that the preceeding file is an executable script – Arpit Oct 16 '12 at 5:44
set PATH= .:$PATH (maybe to much csh?) – Joseph Quinsey Oct 16 '12 at 5:45
@Arpit Well it just tells the shell to execute that program in the current directory. – squiguy Oct 16 '12 at 5:47
Slight correction: in your .bashrc, put export PATH=$PATH:. – Joseph Quinsey Oct 16 '12 at 5:53
@Arpit: No, the ./ tells the shell that it's in the current directory. – Keith Thompson Oct 16 '12 at 6:25
up vote 2 down vote accepted

You can do:

$ ./scanner test.txt
$ scanner test.txt

but it's preferable to have $HOME/bin in your path and your scripts there.

share|improve this answer
+1 for both giving an actual answer, as well as mentioning $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.) – Michael Kjörling Oct 17 '12 at 8:41

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.

share|improve this answer
  1. Add the directory that scanner is in to your path
  2. Move the file scanner to a directory that's already in your path.
  3. Alias scanner to the full path of where the file is.
share|improve this answer

You must log in to answer this question.