DEV Community

taijidude
taijidude

Posted on

Run python scripts with less typing...

When you run a lot of python scripts from the linux command line there is a nice way to save some key strokes.

You have to put the following in the first line of your script. This is a called a shebang line. Although i have no idea why it has that name.

#!/usr/bin/env python
Enter fullscreen mode Exit fullscreen mode

After this you have to make the script executable.

chmod +x generate.py
Enter fullscreen mode Exit fullscreen mode

If all this is done, you can just run the script like a regular shell script.

before:

python test.py
Enter fullscreen mode Exit fullscreen mode

after:

./test.py
Enter fullscreen mode Exit fullscreen mode

Top comments (0)