snazzybouche
snazzybouche

Reputation: 2427

How do I bind a terminal command to the execution of a shell script?

Say I have a programme that's run from a shell script:

cd /path/to/file/
./programme

How would I bind that to a single command so I only have to type one thing? ie for most installed programmes I can just type the name of the programme and it's running

programme

Upvotes: 0

Views: 1126

Answers (2)

Majid DarvishFard
Majid DarvishFard

Reputation: 26

you must add your script path in $PATH variable in ~/.bashrc file ,like this:

export PATH=$PATH:/path/to/file

or put your script in linux binary directory like /usr/local/bin , /usr/bin

Upvotes: 1

Nithin
Nithin

Reputation: 53

For this you need to create a script with a name and give execute permission to it. Then Copy that script to /usr/bin directory . Now you can run your scrpt as a command in terminal. For details please refer the link https://devopsmanual.in/2018/04/17/create-our-own-script-in-linux/

Upvotes: 0

Related Questions