Lab ^

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Lab ^
# 1  
Old 03-07-2013
Ubuntu Lab ^

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Filter a file for lines that have exactly 5 numbers in a row.


2. Relevant commands, code, scripts, algorithms:
Use the grep command with any options and wild cards.


3. The attempts at a solution (include all code and scripts):
Code:
 grep "[0-9]\{5\}" filterdata 
grep [0-9][0-9][0-9][0-9][0-9] filterdata
grep "[0-9]\{5,\}" filterdata
grep "[0-9]\{5\}" * filterdata
grep "[0-9]{5}" filterdata
grep "[0-9]\{5\}" . filterdata

(filterdata being the file Iam trying to Filter)


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Owens Community College, Toledo, Ohio, Thomas McLeary, EET 208

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by Scrutinizer; 03-07-2013 at 09:30 AM.. Reason: code tags
# 2  
Old 03-07-2013
Code:
$ cat file
123456
12345
12345a dfdf
121
12345 dfd
$ grep -w "[0-9]\{5\}" file
12345
12345 dfd

This User Gave Thanks to anbu23 For This Post:
# 3  
Old 03-07-2013
Check out the ^ and $ anchors in regular expressions. Also it says "numbers", not "digits" . -w may work but is not a portable grep option.
# 4  
Old 03-07-2013
So if a line is like :

Code:
bla 12 34 890 56 78 bla bla

... it does have exactly 5 numbers in a row
# 5  
Old 03-07-2013
Thanks for the aid. Tried the grep -w "[0-9]\{5\} file with no luck. the numbers are consecutive (12345) and I need to show the complete line that they are in.
# 6  
Old 03-07-2013
The solution just depends on the way you understand the statement :

Code:
"Filter a file for lines that have exactly 5 numbers in a row"

1) do "numbers" stand for "digit" ?

2) what does "in a row" mean ? separated by a space ? other ?

3) does this means that the lines does have and only have 5 numbers in a row?

4) or may the line contain other non-numeric characters (may those "5 numbers in a row" be placed anywhere in the line) ?
# 7  
Old 03-07-2013
Lab example

this line has four 1234 numbers
this line has five 12345 numbers
this line has six 123456 numbers
this line has seven 1234567 numbers
this line has eight 12345678 numbers
part one of the lab is to just return the line with five numbers.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Hardware

Lab server organized software

Hello, Do you have any suggestion of any tool (web based preferably) about how to organize a lab environment? Now i save some info in excel sheet (one rack per column) , but i was thinking if any software exists. Thanks in advance! (2 Replies)
Discussion started by: @dagio
2 Replies

2. Homework & Coursework Questions

System Admin. Lab

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a group id with your last name. Create 2 user IDs using your last name and the numbers 1 and 2. For each... (3 Replies)
Discussion started by: Jagst3r21
3 Replies

3. Homework & Coursework Questions

Processes Lab

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here are my directions. I am pretty sure I am doing this right, but I just want someone more experienced to look... (4 Replies)
Discussion started by: Jagst3r21
4 Replies

4. Hardware

Electricity Savings for home lab

So, I have a kindof off the wall question. I've got 10 computers which I inherited from a charter school that closed that I did their admin work for. They're not servers, just workstations with ubuntu server running on them. I had them all up and running at one point... but crimineys the load on my... (8 Replies)
Discussion started by: jtollefson
8 Replies

5. Shell Programming and Scripting

help me with lab im new to bash....

Write a script that copies the file tree (including subdirectories) in your home directory. As the initial directory to take the directory / usr / share / doc, as the destination directory using the directory $ {HOME} / doc. Write a script corresponding to paragraph 1. Additional conditions: a)... (1 Reply)
Discussion started by: elginmulizwa
1 Replies

6. Homework & Coursework Questions

shell scripting while loop lab 15 help

hi.. this is shell scripting lab15.sh i dont understand this lab i am at the screen shot part. i was wondering if someone can take a quick look at this lab i have linked the doc below. i dont know where to start i have did the Required Errorlevels Errorlevel # but dont... (1 Reply)
Discussion started by: beerpong1
1 Replies

7. Homework & Coursework Questions

Help completing lab.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: ''you are missing the /home/smichaels/Labs/lab2b/group file, please create it as per step 12 of the lab. once... (4 Replies)
Discussion started by: ink
4 Replies

8. Shell Programming and Scripting

cant complete lab ???

heres the lab i did everything but when i issue the automated lab check. but it gives me this everytime ''you are missing the /home/smichaels/Labs/lab2b/group file, please create it as per step 12 of the lab. once you have corrected this problem, re-run the uli101.023 program'' im... (1 Reply)
Discussion started by: ink
1 Replies

9. Programming

Shell Script Lab

In the following Shell Script can anyone help me? What are the total scripts? What are the total binaries? What are the total files? #!/bin/sh GREP="/bin/grep -q" if ; then if ; then for | in ${I}/* ;do file ${I} | ${GREP} "executable" && echo "${I} is a binary" file ${I} |... (1 Reply)
Discussion started by: rktompsett
1 Replies

10. UNIX for Dummies Questions & Answers

VMWare Workstation for home lab

I was wondering if anyone has used VMWare Workstation? I wanted to practice and learn Unix in a networking environment and have my own home lab. However room and money prevent me from buying several computers to do so. Any input would help thank you. (0 Replies)
Discussion started by: vedder191
0 Replies
Login or Register to Ask a Question

Featured Tech Videos