Oct 24


Shells, terminals, and such


Basic Bash


Subshells


Simple bash scripts

Prefix every shell script with the line
#!/bin/bash
The "#!" tells Linux that whatever follows is to be interpeted/executed using the /bin/bash command (i.e., the bash shell). Put your shell script in a file, say myscript.sh, and make the script executable by doing chmod u+x myscript.sh. To execute the script, just type its name as a command. However, just typing myscript.sh at the command prompt might not work. You would need to do ./myscript.sh, to indicate the path (i.e., the current directory) location of the script. If you would like the shell to find the path automatically, you must suitably set the PATH environment variable. For instance, let us suppose this script is in a directory called /home/jimmy/cs2204. You do:
PATH=$PATH:/home/jimmy/cs2204
in essence, appending "/home/jimmy/cs2204" to the current value of PATH and making the result to be the new value of PATH. From this point onwards, you can get away with just typing myscript.sh.


Some cool stuff



Return Home