Question

Using UNIX commands (or the terminal application on Mac) Write the command to retrieve the accessions...

Using UNIX commands (or the terminal application on Mac)

Write the command to retrieve the accessions number from the files called accessions.txt with the following criterion:

  1. contain the number 5
  2. contain the letter d or e
  3. contain the letters d and e in that order
  4. contain the letters d and e in that order with a single letter between them
  5. contain both the letters d and e in any order
  6. start with x or y
  7. start with x or y and end with e
  8. contain three or more digits in a row
  9. end with d followed by either a, r or p

using this file:

accessions.txt

xkn59438
yhdck2
eihd39d9
chdsye847
hedle3455
xjhd53e
45da
de37dp

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Commands

a. grep 5 accessions.txt | sed 's/[^0-9]*//g'
b. grep -e d -e e accessions.txt | sed 's/[^0-9]*//g'
c. grep -E "d.*e" accessions.txt | sed 's/[^0-9]*//g'
d. grep -E "d.e" accessions.txt | sed 's/[^0-9]*//g'
e. grep -E "(d.*e|e.*d)" accessions.txt | sed 's/[^0-9]*//g'
f. grep -E "^(x|y)" accessions.txt | sed 's/[^0-9]*//g'
g. grep -E "^(x|y).*e$" accessions.txt | sed 's/[^0-9]*//g'
h. grep -E "[0-9]{3}" accessions.txt | sed 's/[^0-9]*//g'
i. grep -E "d(a|r|p)$" accessions.txt | sed 's/[^0-9]*//g'

Explanation:

The output of each grep command is passed to the same sed command to filter the text for numbers. Refer to regex documentation or leave a comment if you have any queries!

a. just grep 5 from accessions.txt

b. use two patterns by using the -e flag for both

c. .(dot) means any character (only once) so .* (dot)(asterisk) means any number of characters between d and e

d. "d.e" is specified indicating d followed by any character occurring once followed by e

e. Here | (or) is used and the two patterns are provided (one for d followed by e and another for e followed by d)

f. ^ indicates the start of a string. so ^(x|y) indicates a string that begins with either x or y

g. Again ^(x|y) indicates the string begins with either x or y. $ denotes the end of the string. So .*(any number of characters) followed by e at the end

h. [0-9] indicated a digit between 0 and 9. [0-9]{3} means 3 digits occurring together

i. d(a|r|p)$ means a string ending with either da, dr or dp

OUTPUT:


Add a comment
Know the answer?
Add Answer to:
Using UNIX commands (or the terminal application on Mac) Write the command to retrieve the accessions...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • These are linux commands. Type cd /usr/share/dict. The file words is the Linux English dictionary. You...

    These are linux commands. Type cd /usr/share/dict. The file words is the Linux English dictionary. You will use egrep to explore this file. Your answers below will be the egrep command that solves the problem. a.List all words that have the letter a followed immediately by the letter z. b.List all words that have the letter a followed sometime later by the letter z (there must be at least one letter in between). c.List all words that start with the...

  • I have to do this question using UNIX commands (or terminal on Apple computers) If you...

    I have to do this question using UNIX commands (or terminal on Apple computers) If you have a data file called datafile(below) Show only line 3 Show only the last line For all lines that have the string key in it change the word more to other Print lines that follow this pattern of four characters: the first letter is an m and the last is a n – the two intervening letters can be anything. Print all lines that...

  • QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A....

    QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A. List all files and directories recursively starting from / B. List a file names * in / C. List all files in / directory D. List all files and directories in / directory QUESTION 2 Which command is used to extract a column/field from a text file / input. A. paste B. get C. cut D. tar QUESTION 3 Which command creates an empty...

  • Unix/Linux The purpose of this lab is to practice the commands to manage and organize files...

    Unix/Linux The purpose of this lab is to practice the commands to manage and organize files and directories: How would one go about this? Thanks. Task 1: Preliminaries: 1) If you have not already done so, create a directory called bin under your HOME directory. 2) If you have not already made a copy (using ftp) of the file called famous.dat from the Assignment#1, do that now. 3) Make bin the active/working directory. Task 2: Perform all of the following...

  • Write a script using simple shell commands. The script takes a command line argument that specifies...

    Write a script using simple shell commands. The script takes a command line argument that specifies a directory dir. The script first changes directory to dir, then prints the following in sequence: (a) A line starting “Current date and time: ”. Then on the same line, the current time and date. (b) A line starting “Current directory is : ”. Then, on the same line, the absolute pathname of the current working directory. (c) An empty line (d) The line...

  • e) In the context of Unix file system , what does "path" means? f) Write down...

    e) In the context of Unix file system , what does "path" means? f) Write down the absolute path for the main.cpp in the timeproj directory g)Write down the relative path from inside timeproj directory to the prgm1.cpp file h)Write down the Unix commands and key strokes needed to create a new sourcefile named time.cpp and then save it to disk using the pico editor. i) In Unix each file has three access modes, namely r,w, and x. 1) Write...

  • Your task for this project is to write a parser for a customer form. You need to develop a Java a...

       Your task for this project is to write a parser for a customer form. You need to develop a Java application using Parboiled library. Your program should include a grammar for the parser and display the parse tree with no errors. Remember that your fifth and sixth assignments are very similar to this project and you can benefit from them. The customer form should include the following structure: First name, middle name (optional), last name Street address, city, state (or...

  • Write an egrep command that prints out all the valid ID numbers in the file lines.txt....

    Write an egrep command that prints out all the valid ID numbers in the file lines.txt. A valid ID number has the following rules: It starts with a hash mark (#) followed by 3 digits, one dash (-) and another group of 5 digits. There is an optional letter in front (before the hash mark) that can be from A to F (including A and F). NOTE: Look at the lines.txt file for examples of valid and invalid ID numbers....

  • INFO 1211

    Lab 0: Essential UNIX OperationsObjectivesAt the end of this of lab, you should be able to:securely      log in to a remote computer running a UNIX-like operating systemread the      manual page for any commanduse the      UNIX file systemedit a      text fileNotes:·         In order to get familiar with UNIX, do all your work on UNIX.·         A command line interface may be harder to learn, but can be more powerful for scripting and automating tasks.·        ...

  • Q4) Write a C program named "hw3q4.c” that takes three string inputs from the command line...

    Q4) Write a C program named "hw3q4.c” that takes three string inputs from the command line arguments that represent file names. The first and second files contain four sorted integer numbers that represent set elements. The main process creates a child process that shares the three files. The child process determines the intersection set of two sets and saves the line: "Child process PID: xxxx Intersection of (x, x, x, x) and (y, y, y, y) (z, z, z, z)"...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT