Showing posts with label bash scripting basics. Show all posts
Showing posts with label bash scripting basics. Show all posts

Saturday, December 10, 2016

How to alias bash scripts and execute from terminal?

You wrote a bash script and now you have to run it, but you don't know how.  Well this is an easy task. We can do this with just few terminal commands.
  • First you need to make the file as an executable. Use chmod to do so. chmod changes the file mode bits of each fiven file according to the mode , which can be either symbolic or numbr.
    In your terminal type:  chmod +x filename.sh
  • Now add an alias in the .bashrc file
    gedit .bashrc
     at the last line of file type this:
    alias filename ='filename.sh'
  • Save and close the file 
  • Type source ~/.bashrc  to apply the changes you made to this file
  • Now open terminal and just type the alias you provided to your application. Now you need not create the directory path and execute again and again to run a specific file. Just use the alias.

About Me

authorHello, my name is Jack Sparrow. I'm a 50 year old self-employed Pirate from the Caribbean.
Learn More →