Introduction+of+basic+Unix+commands


 * UNIX Command Line workshop **

Your instructor is Ke Bi.


 * MPORTANT NOTES **


 * 1. **** This workshop material is based on “UNIX Tutorial for Beginners” ( [] ) with modifications. “UNIX Tutorial for Beginners” is covered by a [|Creative Commons licence] . If you need to download a copy of the original tutorial please go to http://www.ee.surrey.ac.uk/Teaching/Unix/download.html **

2. The material below is intended for the in-class instruction. Others trying to learn this material offline can follow along on any Unix (like) machine, however, please be aware the file names and path names will be different on your machine.


 * Requirements **

The module requires that you use a recent MacOS or Linux based system. Future versions of the module may accommodate Microsoft Windows users.


 * Using the UNIX shell **

Your time in the UNIX environment will be spent in the **shell**, which runs in the Terminal window, if you're using Mac OS. The shell allows you to move and copy files, run programs, and more.


 * How do I open my terminal window? **

In Mac OS, you can open a new terminal window by opening the Finder, selecting the Applications folder, then the Utilities sub-folder, and then double-clicking on the Terminal application. You may want to drag the Terminal icon to your Application Dock for ready access going forward.

Alternatively, you can just use Spotlight to search for "Terminal" each time, and open the application after it is listed in the Spotlight results list.

In Linux environments, your terminal program will depend on the version of Linux you have installed. If you are using Linux and you don't know how to open a terminal, raise your hand and let us know now.


 * Accessing your temporary CGRL account **

The next step is to login to the CGRL system (poset.cgrl.berkeley.edu) with your user account and password. You can do this with the ssh command. code Kes-MacBook-Pro:~ kebi$ ssh workshop@poset.cgrl.berkeley.edu Password: [workshop@poset ~]$ code


 * 1.1 Listing files and directories **

When you first login, your current working directory is your home directory.
 * ls (list) **

To find out what is in your home directory, type code [workshop@poset ~]$ ls file1.txt code

The ** ls ** command lists the contents of your current working directory. ** ls ** does not, in fact, cause all the files in your home directory to be listed, but only those ones whose name does not begin with a dot (.). Files beginning with a dot (.) are known as hidden files and usually contain important program configuration information. They are hidden because you should not change them unless you are very familiar with UNIX!!! To list all files in your home directory including those whose names begin with a dot, type code [workshop@poset ~]$ ls -a . .. .bash_logout .bash_profile .bashrc .emacs file1.txt code
 * ls ** is an example of a command which can take options: ** -a ** is an example of an option. The options change the behavior of the command. There are online manual pages that tell you which options a particular command can take, and how each option modifies the behavior of the command. (See later in this tutorial)

** 1.2 Making Directories **
 * mkdir (make directory) **

We will now make a subdirectory in your home directory to hold the files you will be creating and using in the course of this tutorial. To make a subdirectory called ** unixstuff ** in your current working directory type code [workshop@poset ~]$ mkdir unixstuff code

To see the directory you have just created, type code [workshop@poset ~]$ ls file1.txt unixstuff code ** 1.3 Changing to a different directory ** The command ** cd //directory// ** means change the current working directory to 'directory'. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree.
 * cd (change directory) **

To change to the directory you have just made, type code [workshop@poset ~]$ cd unixstuff code Type ** ls ** to see the contents (which should be empty) code [workshop@poset unixstuff]$ls code Now create a new directory **backups** under **unixstuff** code [workshop@poset unixstuff]$ mkdir backups code ** 1.4 The directories. and .. **  Still in the **unixstuff** directory, type code [workshop@poset unixstuff]$ls -a . .. backups code As you can see, in the **unixstuff** directory (and in all other directories), there are two special directories called (**.**) and (**..**) In UNIX, (**.**) means the current directory, so type code [workshop@poset unixstuff]$ cd. code means stay where you are (the **unixstuff** directory). This may not seem very useful at first, but using (**.**) as the name of the current directory will save a lot of typing, as we shall see later in the tutorial.

(**..**) means the parent of the current directory, so typing code [workshop@poset unixstuff]$ cd .. code will take you one directory up the hierarchy (back to your home directory). Note: typing ** cd ** with no argument always returns you to your home directory. This is very useful if you are lost in the file system. ** 1.5 Pathnames **
 * pwd (print working directory) **

Pathnames enable you to work out where you are in relation to the whole file-system. For example, to find out the absolute pathname of your home directory, type ** cd ** to get back to your home directory code [workshop@poset unixstuff]$ cd .. code and then type code [workshop@poset ~]$ pwd /global/home/workshop code The full pathname to the home directory will look something like this -
 * /global/home/username **

** 1.6 More about home directories and pathnames **
 * Understanding pathnames **

First type ** cd ** to get back to your home directory code [workshop@poset unixstuff]$ cd code

Then type **ls** to list the contents of your **unixstuff** directory code [workshop@poset ~]$ ls unixstuff backups code

Now type code [workshop@poset ~]$ ls backups ls: backups: No such file or directory code The reason is, **backups** is not in your current working directory. To use a command on a file (or directory) not in the current working directory (the directory you are currently in), you must either ** cd ** to the correct directory, or specify its full pathname. To list the contents of your backups directory, you must type code [workshop@poset ~]$ ls unixstuff/backups code Home directories can also be referred to by the tilde **~** character. It can be used to specify paths starting at your home directory. So typing code [workshop@poset ~]$ ls ~/unixstuff backups code will list the contents of your unixstuff directory, no matter where you currently are in the file system.
 * ~ (your home directory) **


 * 2.1 Copying Files **
 * cp (copy) **
 * cp //file1 file2// ** is the command which makes a copy of **file1** in the current working directory and calls it **file2**

First, ** cd ** to your home directory and type **ls**. code [workshop@poset ~]$ cd [workshop@poset ~]$ ls file1.txt unixstuff code now make a copy of **file1.txt** and call the copy **file2.txt** code [workshop@poset ~]$ cp file1.txt file2.txt code now list all the contents in your home directory code [workshop@poset ~]$ ls file1.txt file2.txt unixstuff code Now try something more fancier: make a copy of **file1.txt** to the directory **unixstuff** and name this copy **file3.txt** code [workshop@poset ~]$ cp file1.txt unixstuff/file3.txt code Check the content in **unixstuff** code [workshop@poset ~]$ ls unixstuff backups file3.txt code Now **cd** to **unixstuff** code [workshop@poset ~]$ cd unixstuff code Now make a copy of **file1.txt** to the current directory and name it **file5.txt** code [workshop@poset unixstuff]$ cp ../file1.txt file5.txt code Now make a copy of **file1.txt** to the current directory without renaming it code [workshop@poset unixstuff]$ cp ../file1.txt. code Don't forget the dot ( ** . ** ) at the end. Remember, in UNIX, the dot means the current directory. ** 2.2 Moving files **
 * mv (move) **

To move a file from one place to another, use the ** mv ** command. This has the effect of moving rather than copying the file, so you end up with only one file rather than two. It can also be used to rename a file, by moving the file to the same directory, but giving it a different name. We are now going to move file1.txt to your backup directory. This can be done in many different ways. Here I just list one example: cd to your home directory code [workshop@poset unixstuff]$ cd code display all the content in home directory code [workshop@poset ~]$ ls file1.txt file2.txt unixstuff code now move **file1.txt** to the directory **backups** code [workshop@poset ~]$ mv file1.txt unixstuff/backups code Now check the content in the home directory again by using **ls** code [workshop@poset ~]$ ls file2.txt unixstuff code You can see **file1.txt** is gone. Now check the content in the directory backups code [workshop@poset ~]$ ls unixstuff/backups file1.txt code ** 2.3 Removing files and directories **
 * mv //file1 file2// ** moves (or renames) **file1** to **file2**
 * rm (remove), rmdir (remove empty directory) **

To delete (remove) a file, use the ** rm ** command. Now **cd** to your **unixstuff** directory and list all the content, type code [workshop@poset ~]$cd unixstuff [workshop@poset unixstuff]$ ls backups file3.txt file5.txt code No remove (permanently!) **file3.txt** and **file5.txt** from **unixstuff**, and then list the content code [workshop@poset ~]$ rm file3.txt file5.txt [workshop@poset unixstuff]$ ls backups code Now make a new directory test under **unixstuff** and use **rmdir** to remove it. Make sure to check the content of **unixstuff** before and after running **rmdir** code [workshop@poset unixstuff]$ mkdir test [workshop@poset unixstuff]$ ls backups test [workshop@poset unixstuff]$ rmdir test [workshop@poset unixstuff]$ ls backups code

** 2.4 Displaying the contents of a file on the screen ** Before you start the next section, you may like to clear the terminal window of the previous commands so the output of the following commands can be clearly understood.
 * clear (clear screen) **

Now **cd** to your home directory code [workshop@poset unixstuff]$ cd code Type **clear** in the shell code [workshop@poset ~]$ clear code This will clear all text and leave you with the $ prompt at the top of the window.

Now list the content by using **ls** code [workshop@poset ~]$ ls file2.txt unixstuff code code [workshop@poset ~]$ mv unixstuff/backups/file1.txt. [workshop@poset ~]$ ls file1.txt file2.txt unixstuff code
 * file2.txt ** is a copy of **file1.txt**, but we have moved **file1.txt** to the directory **backups**. Now we can move **file1.txt** back. Then you can type **ls** to check the content

The command ** cat ** can be used to display the contents of a file on the screen. Type: code [workshop@poset ~]$ cat file1.txt >Transcript1 CAGGCTTAGCG... >Transcript2 CAGAGCCTCCA… … code As you can see, the file is longer than the size of the window, so it scrolls past making it unreadable.
 * cat **

The command ** less ** writes the contents of a file onto the screen a page at a time. Type code [workshop@poset ~]$ less file1.txt code Press the ** [space-bar] ** if you want to see another page, type ** [q] ** if you want to quit reading. As you can see, ** less ** is used in preference to ** cat ** for long files.
 * less **

The ** head ** command writes the first ten lines of a file to the screen.
 * head **

First **clear** the screen then type **head file1.txt** code [workshop@poset ~]$ clear [workshop@poset ~]$ head file1.txt >Transcript1 CAGGCTTAGCG... >Transcript2 CAGAGCCTCCA… … code Then type code [workshop@poset ~]$ head -5 file1.txt >Transcript1 CAGGCTTAGCG... >Transcript2 CAGAGCCTCCA… >Transcript3 code The above shows the first 5 lines in **file1.txt**

The ** tail ** command writes the last ten lines of a file to the screen. Its function is opposite to head. Please give it a try. In the shell, type **clear**, then **tail file1.txt**, then **tail -5 file1.txt** ** 2.5 Searching the contents of a file **
 * tail **
 * grep **

code [workshop@poset ~]$ grep “Transcript” file1.txt >Transcript1 >Transcript2 >Transcript3 … code As you can see, ** grep ** has printed out each line containing the word “Transcript”.
 * grep ** is one of many standard UNIX utilities. It searches files for specified words or patterns. First **clear** the screen, then type

Now try typing code [workshop@poset ~]$ grep “transcript” file1.txt code The ** grep ** command is case sensitive; it distinguishes between “Transcript” and “transcript”.

To ignore upper/lower case distinctions, use the **-i** option, i.e. type code [workshop@poset ~]$ grep -i “transcript” file1.txt >Transcript1 >Transcript2 >Transcript3 … code Other common and useful options for grep include: **-v** display those lines that do NOT match **-n** precede each matching line with the line number **-c** print only the total count of matched lines

Try some of them and see the different results. Don't forget, you can use more than one option at a time, for example, the number of lines without the words “Transcript” or “transcript” is code [workshop@poset ~]$ grep -ivc "Transcript" file1.txt 11 code A handy little utility is the ** wc ** command, short for word count. To find out how many lines the file has, type code [workshop@poset ~]$ wc -l file1.txt 22 code
 * wc (word count) **

** 3.1 Redirecting the Output ** Most processes initiated by UNIX commands write to the standard output (that is, they write to the terminal screen), and many take their input from the standard input (that is, they read it from the keyboard). There is also the standard error, where processes write their error messages, by default, to the terminal screen


 * echo ** (writes its arguments to standard output)

In a terminal window type code [workshop@poset ~]$ echo hello! hello! code

We now direct the output **hello!** to a new file called **test**, check the content of **test** using **cat** code [workshop@poset ~]$ echo hello! > test [workshop@poset ~]$ cat test hello! code We use the **>** symbol to redirect the output of a command.

For example, to create a file called **list1** containing a list of fruit, type code [workshop@poset ~]$ cat > list1 code Then type in the names of some fruit. Press ** [return] ** after each one code pear banana apple code
 * ^d (Control + d to stop) **

What happens is the ** cat ** command reads the standard input (what you typed via the keyboard) and the **>** redirects the output into a file called **list1**

To read the contents of the file, type **cat file1** or **less file1** code [workshop@poset ~]$ cat list1 pear banana apple code The form **>>** appends standard output to a file. So to add more items to the file **list1**, type code [workshop@poset ~]$ cat >> list1 code Then type in the names of more fruit

code peach grape orange code
 * ^d (Control + d to stop) **

To read the contents of the file, type code [workshop@poset ~]$ cat list1 pear banana apple peach grape orange code Now we can write some vegetables to a new file called **list2, t** hen type in the names of some vegetables

code [workshop@poset ~]$ cat > list2 lettuce carrot kale code
 * ^d (Control + d to stop) **

You should now have two files. One contains six fruit, and the other contains three vegetables. We will now use the ** cat ** command to join (concatenate) **list1** and **list2** into a new file called **biglist**. Type code [workshop@poset ~]$ cat list1 list2 > biglist code What this is doing is reading the contents of **list1** and **list2** in turn, then outputing the text to the file **biglist**

To read the contents of the new file, type code [workshop@poset ~]$ cat biglist pear banana apple peach grape orange lettuce carrot kale code The command ** sort ** alphabetically or numerically sorts a list. Type code [workshop@poset ~]$ sort biglist apple banana carrot grape kale lettuce orange peach pear code To output the sorted list to a file called **sortlist**, type the following code [workshop@poset ~]$ sort biglist > sortlist code ** 3.2 Pipes ** **I (pipe)** take the output of one command and use it as input for the command after the **pipe**. Useful for chaining commands which have one output and accept one input

An example: we want to **sort** the file biglist alphabetically, then display the first 5 lines in the terminal window, then from these five lines we want to **grep** any lines containing letter “r” or “R” and then count how many lines meet this category code [workshop@poset ~]$ sort biglist | head -5 | grep -i “r” | wc -l 2 code

** 4.1 Wildcards ** The character * is called a wildcard, and will match against none or more character(s) in a file (or directory) name. For example, in your **home** directory, type code [workshop@poset ~]$ ls list* list1 list2 code This will list all files and subdirectories in the current directory starting with **list (list…)**
 * The characters * and ? **

Try typing code [workshop@poset ~]$ ls *list biglist sortlist code This will list all files and subdirectories in the current directory ending with **list (…list)**

Now typing code [workshop@poset ~]$ ls *list* biglist list1 list2 sortlist code This will list all files and subdirectories in the current directory containing **list (…list…)**

The character **?** will match exactly one character. So ** ls ?ouse ** will match files like **house** and **mouse**, but not **grouse**.

Try typing code [workshop@poset ~]$ ls ?list ls: ?list: No such file or directory code Now try typing code [workshop@poset ~]$ ls ?ist1 list1 code ** 4.2 Filename conventions ** We should note here that a directory is merely a special type of file. So the rules and conventions for naming files apply also to directories. In naming files, characters with special meanings such as **/ * & %**, should be avoided. Also, avoid using spaces within names. The safest way to name a file is to use only alphanumeric characters, that is, letters and numbers, together with _ (underscore) and. (dot). File names conventionally start with a lower-case letter, and may end with a dot followed by a group of letters indicating the contents of the file. For example, all files consisting of C code may be named with the ending .c, for example, prog1.c. Then in order to list all files containing C code in your home directory, you need only type ** ls *.c ** in that directory. ** 4.3 Getting Help **
 * man (on-line manuals) and whatis **

There are on-line manuals which gives information about most commands. The manual pages tell you which options a particular command can take, and how each option modifies the behavior of the command. Type **man** command to read the manual page for a particular command. For example, to find out more about the ** wc ** (word count) command, type code [workshop@poset ~]$ man wc code Alternatively, type code [workshop@poset ~]$ whatis wc code
 * whatis ** gives a one-line description of the command, but omits any information about options etc.

5.1 Other commonly used UNIX commands The df command reports on the space left on the file system. For example, to find out how much space is left on the fileserver, type code [workshop@poset ~]$ df -h. Filesystem Size Used Avail Use% Mounted on /dev/sdb 15T 9.0T 5.6T 62% /global code
 * df**
 * -h** means that it prints sizes in human readable format (e.g., 1K 234M 2G)

The du command outputs the size of a file or a directory in kilobytes. Below is an example for output size of a file code [workshop@poset ~]$ du -h file1.txt 12K code
 * du**

This command compresses a file. For example, to compress **file1.txt**, type code [workshop@poset ~]$ gzip file1.txt code Now list the content in home directory code [workshop@poset ~]$ ls biglist file1.txt.gz list1 list2 sortlist test unixstuff code Now **file1.txt** is zipped and is ended with .gz
 * gzip**

To unzip the file, use the **gunzip** command code [workshop@poset ~]$ gunzip file1.txt.gz code

Now list the content in home directory code [workshop@poset ~]$ ls biglist file1.txt list1 list2 sortlist test unixstuff code

The shell keeps an ordered list of all the commands that you have entered. Each command is given a number according to the order it was entered. code [workshop@poset ~]$ history …lots of commands… code Now we only want to repeat the last command code [workshop@poset ~]$ !! code Now we only want to repeat the second command in the history code [workshop@poset ~]$ !2 code
 * history**


 * nano ** (a small and friendly text editor)

Create an empty file sequence.fasta code [workshop@poset ~]$ nano sequence.fasta code and copy the following fasta sequences to this file

>seq1 AGTACGTAGTAGCTGCTGCTACGTGCGCTAGCTAGTACGTCAA TCGTACGTCGACTGATCGTAGCTACGTCGTACGTAGGTACGTT CGACGTAGATGCTAGCTGACTCGATGC >seq2 CGATCGATCGTACGTCGACTGATCGTAGCTACGTCGTACGTAG GTACGTGATCGTACGTCGACTGATCGTAGCTATCGTAGCTACC CATCGTCAGTTACTGCATGCTCG >seq3 GATCGTACGTGTAGCTGCTGTAGCTGATCGTACGGTAGCAGCT CGTCGACTGATCGTAGCTGATCGTACGTCGACTGATCGTAGCT AGTACGTAGTAGCTGTAGCTGATCGTACGTAGCTGATCGTACG >seq4 CGATCGATCGTACGTCGACTGATCGTAGCTACGTCGTACGTAG GTACGTGATCGTACGTCGACTGATCGTAGCTATCGTAGCTACC GTAGATGCTAGCTGACTCGAT

Type **ctrl+X**, **Y**, and then **return** to quit. Now peek inside this file by using **cat** or **less**

code [workshop@poset ~]$ wget code
 * wget ** (retrieve files from web servers)

Read the contents of **gene_exp.diff**, type code [workshop@poset ~]$ less -S gene_exp.diff code
 * cut ** (extract sections from each line of input)
 * -S ** causes lines longer than the screen width to be chopped rather than folded

Extract the third column from gene_exp.diff and display it using less code [workshop@poset ~]$ cut -f 3 gene_exp.diff | less code Extract the third column from gene_exp.diff, exclude lines containing “-“, sort the names alphabetically and then display it using **less** code [workshop@poset ~]$ cut –f 3 gene_exp.diff | grep –v “-“ | sort | less code


 * uniq ** (when fed a text file, outputs the file with adjacent identical lines collapsed to one)

Firstcreates a new file **uniq_test.txt** using nano and copy the following content to this file gene1 A gene1 A  gene6 F  gene6 F  gene6 F  gene1 A  gene2 B  gene2 B  gene4 D  gene5 E  gene6 F  gene6 F  gene6 F  gene1 A  gene1 A  gene2 B  gene2 B  gene2 B  gene3 C  gene4 D  gene4 D

Now we want to remove duplicated lines from the file code [workshop@poset ~]$ sort uniq_test.txt | uniq gene1 A gene2 B gene3 C gene4 D gene5 E gene6 F code

Print only those lines which are not repeated (unique) in the input. code [workshop@poset ~]$ sort uniq_test.txt | uniq -u gene3 C gene5 E code

Print only those lines which are repeated in the input. code [workshop@poset ~]$ sort uniq_test.txt | uniq -d gene1 A gene2 B gene4 D gene6 F code

You can also get some statistics out of **uniq** with the **-c** option code [workshop@poset ~]$ sort uniq_test.txt | uniq -dc 5 gene1 A 5 gene2 B 3 gene4 D 6 gene6 F code

{A,B,C} expands all the elements within the braces {1..9} expands a range of elements within the braces
 * {} ** (Brace expansion is a mechanism by which arbitrary strings may be generated)

code [workshop@poset ~]$ echo hello {A,B,C} hello A B C [workshop@poset ~]$ echo hello{A,B,C} helloA helloB helloC code Create several folders with names starting with “folder” under the home directory code [workshop@poset ~]$ mkdir folder_{A,B,C} [workshop@poset ~]$ ls folder* folder_A: folder_B: folder_C: code Create new several empty files with names beginning with “txt” using **touch** under the home directory code [workshop@poset ~]$ touch txt{1..5}.txt [workshop@poset ~]$ ls txt* txt1.txt txt2.txt txt3.txt txt4.txt txt5.txt code


 * find **
 * find ** is useful for finding file or directory names that match certain criteria.

Search the home directory and print any files or directories beginning with **list** code [workshop@poset ~]$ find. -name "list*" ./list1 ./list2 code

Search the home directory to print all subdirectories code [workshop@poset ~]$ find. -type d. ./unixstuff ./unixstuff/backups ./folder_A ./folder_B ./folder_C code

code [workshop@poset ~]$ grep -n “T$” sequence.fasta 3:TCGTACGTCGACTGATCGTAGCTACGTCGTACGTAGGTACGTT 10:GATCGTACGTGTAGCTGCTGTAGCTGATCGTACGGTAGCAGCT 11:CGTCGACTGATCGTAGCTGATCGTACGTCGACTGATCGTAGCT 16:GTAGATGCTAGCTGACTCGAT code The above command **grep** each line ending with a “T” from **sequence.fasta** and print out the line number of that line. $ matches the end of a line code [workshop@poset ~]$ grep -n "^C" sequence.fasta 4:CGACGTAGATGCTAGCTGACTCGATGC 6:CGATCGATCGTACGTCGACTGATCGTAGCTACGTCGTACGTAG 8:CATCGTCAGTTACTGCATGCTCG 11:CGTCGACTGATCGTAGCTGATCGTACGTCGACTGATCGTAGCT 14:CGATCGATCGTACGTCGACTGATCGTAGCTACGTCGTACGTAG code The above command **grep** each line starting with a “C” and print out the line number of that line. ^ matches the beginning of a line code [workshop@poset ~]$ grep -n "^C.*T$" sequence.fasta 11:CGTCGACTGATCGTAGCTGATCGTACGTCGACTGATCGTAGCT code The above command **grep** each line starting with “C”, and ending with “T”, with any letters in between them, and then print out the line number of that line. **.** means any single character (except newline), * means that the preceding item will be matched zero or more times. code [workshop@poset ~]$ grep -A 1 ">Transcript10" file1.txt
 * More about grep **

code code [workshop@poset ~]$ grep -B 1 ">Transcript10" file1.txt code
 * -A ** N[int] means that it will print N lines of trailing context after matching lines.
 * -B ** N[int] means that it will print N lines of leading context before matching lines.

The above two command lines are useful for displaying sequences of a fasta file.

code [workshop@poset ~]$ grep -A 1 ">Trascript1" file1.txt code What happened? It matches Trascript1, Trascript10 and Trascript11 since all there contain “Trascript1”. We just want the sequence after Transcript1 to be printed. We need to add more conditions. Several ways to do this:

code [workshop@poset ~]$ grep -A 1 ">Transcript1$" file1.txt [workshop@poset ~]$ grep -A 1 ">Transcript1\b" file1.txt code
 * \b ** matches the empty string at the edge of a word. It sets a boundary to the matches.

A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline) Here we use sed to find and replace complex string in a file. For example we want to replace seq1 with sequence 1 in the file **sequence.fasta** code [workshop@poset ~]$ sed 's/seq1/gene1/g' sequence.fasta >gene1 AGTACGTAGTAGCTGCTGCTACGTGCGCTAGCTAGTACGTCAA TCGTACGTCGACTGATCGTAGCTACGTCGTACGTAGGTACGTT … code In the above example, **s/A/B/g** means that it will replace A with B in global search.
 * sed ( ** a stream editor**)**

code [workshop@poset ~]$ grep -A 1 ">Transcript1$" file1.txt | sed 's/A/a/g' >Transcript1 CaGGCTTaGCGGTTTaTTGaTGTCTCCCaaGCCaGaGGaaGTCaCCaaaGGGaaGaGTCaCTTGCaGaaaaTGGTTTCCaTTTCaGaCaTTaCaTCCCTGTaCaGCaaCCTGCTCCTGTaCaCGTGTGGGTCCTCTGCCGaaGCCaCCaGGGCTGTCaTGaGaCaCCTTGCCGCTGTGTaTCaaCaTGGCaGCCTGCTaGGGCTTTCTGTTGCCaaGaGGCCTCTCTGGaGaCaGGCaTCTaTGCaaaGTGGGaaGGaCaCCaCTGaGCaaGaaaTTCTGaaaGCTaTCaaCaTCaaTTCCTTTGCaGaGTGTGGCaTCaaTTTaTTCCaTGaGaGTGTaTCTaaaTCaGCCCTGaGCCaaGaaTTCGaaGCTTTCTTTCGT code In the above example, we first find the sequence of Transcript1, transform A to a, and then print the output in the terminal.