command line automation using .sh scripts
Automating Tasks Using .sh Files
Automate tasks using shell scripts and make them accessible from any location in the terminal with the following steps:
- Write your script: Create a .sh file (e.g.,
myscript.sh) containing your commands. - Make it executable: Run
chmod +x /path/to/myscript.sh. - Organize your scripts: Place all your .sh files in a dedicated folder, e.g.,
~/my_shell_scripts. - Edit .bashrc with Vim: Type
vim ~/.bashrcto open .bashrc in Vim. Appendexport PATH="$PATH:/path/to/my_shell_scripts"to add your script folder to the PATH. - Source .bashrc: Apply changes with
source ~/.bashrc. - Execute from anywhere: Just type the script's name (e.g.,
myscript.sh) in the terminal. Note: extension also needs to be specified.
With these steps, your custom scripts are now accessible from any location in the terminal, making automation seamless and efficient.
Comments
Post a Comment