Question

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. Also, you can assume all ID numbers start at the beginning of the line and end with a space (this is useful as egrep will pick up strings within the invalid ID's that are valid).

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

The command will be as follows

egrep -c '^#[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9] | ^[A-F]#[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9]' line.txt

starts with a hash mark (#) followed by 3 digits from 0-9) , one dash (-) and another group of 5 digits from 0-9

[0-9]--> Any number from 0-9

[A-F]--> Any alphabet between A and F includeind both letters

The above command will serach for all IDs starts with a hash mark (#) followed by 3 digits from 0-9) , one dash (-) and another group of 5 digits from 0-9 OR starts with OPTIONAL LETTER [A-Z]hash mark (#) followed by 3 digits from 0-9) , one dash (-) and another group of 5 digits from 0-9

Please note line.txt is not available in the question for sample check

Add a comment
Know the answer?
Add Answer to:
Write an egrep command that prints out all the valid ID numbers in the file lines.txt....
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
  • Write a program that reads in two hexadecimal numbers from a file, hex.dat, and prints out...

    Write a program that reads in two hexadecimal numbers from a file, hex.dat, and prints out the sum of the two numbers in hexadecimal. (As noted in class, first do this without using a file and by reading using the cin > > command) From Wikipedia: "In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0-9 to...

  • Write a program in C language that reads scores and id numbers from a file, finds...

    Write a program in C language that reads scores and id numbers from a file, finds the average score, and assigns each student a grade based on the following rules: Each score > average + 20 gets an A Each score between average + 10 and average + 20 gets a B Each score between average - 10 and average + 10 gets a C Each score between average - 20 and average - 10 gets a D Each score...

  • You must write a C program that prompts the user for two numbers (no command line...

    You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...

  • do numbers 4-8 4. Given any directory, use the Is command to display: • all files...

    do numbers 4-8 4. Given any directory, use the Is command to display: • all files and sub-directories starting with the letter "D" (note do not list anything in any sub-directory) • its immediate sub-directories (sub-directories only, and no other ordinary files) its immediate hidden sub-directories only - take a screenshot (#3-3) that clearly shows the command and the result. 5. Assume that the following files are in the working directory: $ ls intro notesb ref2 section 1 section3 section4b...

  • If i could get any guidance on how to get this started it will be great....

    If i could get any guidance on how to get this started it will be great. My prof. literally just gave us the information below (which are literally just instructions) and I am unsure on how to get started. For this assignment we are going to create a function that reads an input stream and classifies it into “tokens” from a language that we define here. In this language we make the following rules: ● An identifier is a letter...

  • in visual studio build a masm program that prints out the prime numbers in a array...

    in visual studio build a masm program that prints out the prime numbers in a array L1001-Sieve of Eratosthenes Please use your textbook as a reference. Goal: Use what we have learned to generate prime numbers. Prime numbers have many applications in computer science and as such, efficient ways to discover prime numbers can be very useful. Mathematicians have been intrigued by the concept for ages including the Greek mathematician, Eratosthenes of Cyrene (famous for calculating the circumference o the...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

  • Please solve in python and provide comments explaining your codes. Your output must be the same...

    Please solve in python and provide comments explaining your codes. Your output must be the same as the example and result given below in the images. This task is to write a very basic text editor. It allows you to add, delete and modify lines of text.  Use a list of strings to store the lines, with each list element being one line. The elements of the list are modified according the commands given by the user. The editor repeatedly: 1.    displays...

  • please write psedocodes for all of the questions and an algorithm for 2. no coding is...

    please write psedocodes for all of the questions and an algorithm for 2. no coding is required . FIUJELI 95 PIOL 1. (Geometry: Area of a Pentagon) Write a C# program that prompts the user to enter the length from the center of a pentagon to a vertex and computes the area of the pentagon, as shown in the following figure. The formula for computing the area of a pentagon is Area = 2 , where s is the length...

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
ADVERTISEMENT