bash related q a
play

Bash Related Q&A April 10, 2020 Can grep be used to exclude - PowerPoint PPT Presentation

Bash Related Q&A April 10, 2020 Can grep be used to exclude individual words or search for a specific phrase? To remove lines with a specific word: YES To exclude individual words: NO you would use `sed` To search for a specific


  1. Bash Related Q&A April 10, 2020

  2. Can grep be used to exclude individual words or search for a specific phrase? • To remove lines with a specific word: YES • To exclude individual words: NO you would use `sed` • To search for a specific phrase: YES

  3. Can we clear up some of the differences between gzip and gunzip? As well the difference between grep and zgrep? • The “g” in gzip and gunzip is an abbreviation for GNU • GNU is an operating system and an extensive collection of computer software. • If you ignore the g, the commands are simply zip and unzip • When you zip a file you are compressing it, “zipping it up” • We zip files to save storage space on our computers • When you unzip a file you are decompressing it, “unzipping it” • The zgrep is a shortcut when using grep on a gzipped file • zgrep = gunzip – c file.txt | grep

  4. Can we set up two virtual networks from the same instance for two PC and run it at a different time? (in case of your main PC broken or not available) • You can create two separate instances and have them both available • They will both have their own files • You will need to make sure they are both stopped when not in use • Your AWS credit will be charged a small additional fee for the extra ip address and storage you would be using • You would be able to pick which instance you work on • To share your work between the instances you will have to push and pull your changes to and from Github on both instances

  5. Within a command, does order matter? • It depends • A command generally has 3 parts in the following order 1. The command 2. The named options 3. The unnamed arguments • In most cases, the named options can be in any order you want as long as they come after then command and before the unnamed argumentx Command = grep Named options = -v & -c Unnamed arguments = “end” & example.txt

  6. when I am using grep -c to count the occurrence of a word in the fasta file, for example, " USA", will the newline character be included as well? Thank you! • grep – c counts the number of lines which contain your search pattern, the newline character is ignored in this case • When using `wc`, the newline characters are included Number of lines Number of words Number of characters, newline characters included

  7. What is the difference between single quotes and double quotes in code (bash, Python, R)? Are they interchangeable or do they each mean specific things? • In most cases single quotes and double quotes can be used interchangeable • Their difference becomes apparent when working with regular expression (regex) • Single quotes tell the computer to read the text inside exactly as it is written while double quotes allow for variable names to be inserted

  8. Can you introduce the calculation in unix? How to plus, minus, multiply and divide in unix command line? • Math can be done on the command several different ways • One way to perform calculations is to use `bc` which stands for basic calculator • You can use it by entering `bc` and then performing your calculations or send an equation to it and receive the answer

  9. How do you know how to navigate the manual pages of Unix code and be able to identify exactly what needs to used for the command? • Generally when you look at the manual for a command there will be a “Usage” or “Synopsis” with an example of how to run the command • If using the `man` command does not work you can enter the name of the command followed by “ - h” To run makeblastdb the first part you enter is: makeblastdb Next you enter the Arguments Anything inside “[ ]” is optional -dbtype is not inside “[ ]” so it is required Further down the output is a description of what each arugument does The bare minimum call would be something like `makeblastdb -dbtype nucl`

  10. Questions I did not have time to answer while making slide Can we go over writing bash scripts? Can you explain awk/gawk? For the suffix of a file name, sometimes we use .txt, .sh, . fq. So when should we name file in specific suffix?

  11. Some questions I did not have time to answer when making slides • Can you explain awk/gawk? • For the suffix of a file name, sometimes we use .txt, .sh, . fq. So when should we name file in specific suffix? • Can we go over writing bash scripts?

Recommend


More recommend