Creating and Executing a Shell Program

Say you want to set up a number of aliases whenever you log on. Instead of typing all of the aliases every time you log on, you can put them in a file by using a text editor, such as vi, and then execute the file.

Here is what is contained in myenv, a sample file created for this purpose (for bash):

#!/bin/sh
alias ll='ls -l'
alias dir='ls'
alias copy='cp'

myenv can be executed in a variety of ways under Linux.

You can make myenv executable by using the chmod command, as follows, and then execute it as you would any other native Linux command:

						# chmod +x myenv
					

This turns on the executable permission of myenv. You need to ensure one more thing before you can execute myenv—it must be in the search path. ...

Get Red Hat® Linux® 7 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.