简体   繁体   中英

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

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM