This is an old revision of the document!
So far we've made a pretty cool script that takes the reverse complement of a DNA sequence.
Let's build on our previous work to make a full-fledged script.
Now, let's make it executable. That means that we don't have to type “bash” anymore. This will be important when we try to use it as a command.
$ chmod 755 revComp $ ./revComp ACTGTACGGTACAC sequence: ACTGTACGGTACAC complement: TGACATGCCATGTG reverse: CACATGGCATGTCA reverse complement: GTGTACCGTACAGT sequence length: 14
We removed the “bash” but replaced it with dot slash “./” which might seem like the same amount of work.
Currently, our script only works in the directory ~/Bash_Scripts.
$ cd $ bash revComp TAG bash: revComp: No such file or directory
When you log on, you start in your home directory. So you'll get the same result as above.
So how do you make the script work from anywhere?
We are going to:
1. Go to your home directory.
$ cd $ pwd # should be your home directory
2. Make the new directory for finished scripts. By convention, it is called bin
$ mkdir bin $ ls # should see the new directory bin, plus Bash_Scripts and anything you created before
3. Copy the finished script to the new directory. Use the TAB key to help you not type so much.
$ cp Bash_Scripts/revComp bin/ $ ls bin
Is revComp there?
It's not executable yet. We can easily make it executable with chmod.
$ ls -l hello_world -rw-r--r-- 1 fileowner filegroupname 62 Jul 16 12:32 hello_world $ chmod 755 hello_world $ ls -l hello_world -rwxr-xr-x 1 fileowner filegroupname 62 Jul 16 12:32 hello_world
Notice the x in the 4th, 7th, and 10th positions. This means that the file has execute permissions for the file owner, the file group, and everyone, respectively.
Two common permission settings for scripts are:
To learn more about file permissions and these numbers, see file permissions.