Grep expressions homework, need assistance

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Grep expressions homework, need assistance
# 1  
Old 04-14-2011
Grep expressions homework, need assistance

Please dont delete, im listing my assignment and will be editing as i work on it. I am NOT looking for answers but help in understanding how to use grep
1. The problem statement, all variables and given/known data:
For each question, list the command lines used in addition to any other details asked for. Each one of these can be solved with grep or egrep.
Neither piping nor other commands are required. In other words, don't use them in your answer.


I have completed 1-9 now....just need some help with number 10 please

(10)In /etc/protocols, comments are delineated with the # character.
Write a command line that filters out the comment only lines but keeps all lines with data on them. Do not include the output of this one.

This one is kind of like number 9 but i need to take out the comments and leave the data before the comments. File looks like this
Code:
alindner@cs215:~$ cat /etc/protocols
#
# Internet protocols
#
# $FreeBSD: src/etc/protocols,v 1.16 2002/02/10 08:19:58 dd Exp $
#       from: @(#)protocols     5.1 (Berkeley) 4/17/89
#
# See also http://www.iana.org/assignments/protocol-numbers
#
ip      0       IP              # internet protocol, pseudo protocol number
#hopopt 0       HOPOPT          # hop-by-hop options for ipv6
icmp    1       ICMP            # internet control message protocol
igmp    2       IGMP            # internet group management protocol
ggp     3       GGP             # gateway-gateway protocol
ipencap 4       IP-ENCAP        # IP encapsulated in IP (officially ``IP'')
st2     5       ST2             # ST2 datagram mode (RFC 1819)
tcp     6       TCP             # transmission control protocol
cbt     7       CBT             # CBT, Tony Ballardie <A.Ballardie@cs.ucl.ac.uk>
egp     8       EGP             # exterior gateway protocol
igp     9       IGP             # any private interior gateway (Cisco: for IGRP)
bbn-rcc 10      BBN-RCC-MON     # BBN RCC Monitoring
nvp     11      NVP-II          # Network Voice Protocol
pup     12      PUP             # PARC universal packet protocol
argus   13      ARGUS           # ARGUS
emcon   14      EMCON           # EMCON
xnet    15      XNET            # Cross Net Debugger
chaos   16      CHAOS           # Chaos
udp     17      UDP             # user datagram protocol
mux     18      MUX             # Multiplexing protocol
dcn     19      DCN-MEAS        # DCN Measurement Subsystems
hmp     20      HMP             # host monitoring protocol
prm     21      PRM             # packet radio measurement protocol
xns-idp 22      XNS-IDP         # Xerox NS IDP
trunk-1 23      TRUNK-1         # Trunk-1
trunk-2 24      TRUNK-2         # Trunk-2
leaf-1  25      LEAF-1          # Leaf-1
leaf-2  26      LEAF-2          # Leaf-2
rdp     27      RDP             # "reliable datagram" protocol
irtp    28      IRTP            # Internet Reliable Transaction Protocol
iso-tp4 29      ISO-TP4         # ISO Transport Protocol Class 4
netblt  30      NETBLT          # Bulk Data Transfer Protocol
mfe-nsp 31      MFE-NSP         # MFE Network Services Protocol
merit-inp       32      MERIT-INP       # MERIT Internodal Protocol
sep     33      SEP             # Sequential Exchange Protocol
3pc     34      3PC             # Third Party Connect Protocol
idpr    35      IDPR            # Inter-Domain Policy Routing Protocol
xtp     36      XTP             # Xpress Tranfer Protocol
ddp     37      DDP             # Datagram Delivery Protocol
idpr-cmtp       38      IDPR-CMTP       # IDPR Control Message Transport Proto
tp++    39      TP++            # TP++ Transport Protocol
il      40      IL              # IL Transport Protocol
ipv6    41      IPV6            # ipv6
sdrp    42      SDRP            # Source Demand Routing Protocol
ipv6-route      43      IPV6-ROUTE      # routing header for ipv6
ipv6-frag       44      IPV6-FRAG       # fragment header for ipv6
idrp    45      IDRP            # Inter-Domain Routing Protocol
rsvp    46      RSVP            # Resource ReSerVation Protocol
gre     47      GRE             # Generic Routing Encapsulation
mhrp    48      MHRP            # Mobile Host Routing Protocol
bna     49      BNA             # BNA
esp     50      ESP             # encapsulating security payload
ah      51      AH              # authentication header
i-nlsp  52      I-NLSP          # Integrated Net Layer Security TUBA
swipe   53      SWIPE           # IP with Encryption
narp    54      NARP            # NBMA Address Resolution Protocol
mobile  55      MOBILE          # IP Mobility
tlsp    56      TLSP            # Transport Layer Security Protocol
skip    57      SKIP            # SKIP
ipv6-icmp       58      IPV6-ICMP       # ICMP for IPv6
ipv6-nonxt      59      IPV6-NONXT      # no next header for ipv6
ipv6-opts       60      IPV6-OPTS       # destination options for ipv6
#       61                      # any host internal protocol
cftp    62      CFTP            # CFTP
#       63                      # any local network
sat-expak       64      SAT-EXPAK       # SATNET and Backroom EXPAK
kryptolan       65      KRYPTOLAN       # Kryptolan
rvd     66      RVD             # MIT Remote Virtual Disk Protocol
ippc    67      IPPC            # Internet Pluribus Packet Core
#       68                      # any distributed file system
sat-mon 69      SAT-MON         # SATNET Monitoring
visa    70      VISA            # VISA Protocol
ipcv    71      IPCV            # Internet Packet Core Utility
cpnx    72      CPNX            # Computer Protocol Network Executive
cphb    73      CPHB            # Computer Protocol Heart Beat
wsn     74      WSN             # Wang Span Network
pvp     75      PVP             # Packet Video Protocol
br-sat-mon      76      BR-SAT-MON      # Backroom SATNET Monitoring
sun-nd  77      SUN-ND          # SUN ND PROTOCOL-Temporary
wb-mon  78      WB-MON          # WIDEBAND Monitoring
wb-expak        79      WB-EXPAK        # WIDEBAND EXPAK
iso-ip  80      ISO-IP          # ISO Internet Protocol
vmtp    81      VMTP            # Versatile Message Transport
secure-vmtp     82      SECURE-VMTP     # SECURE-VMTP
vines   83      VINES           # VINES
ttp     84      TTP             # TTP
nsfnet-igp      85      NSFNET-IGP      # NSFNET-IGP
dgp     86      DGP             # Dissimilar Gateway Protocol
tcf     87      TCF             # TCF
eigrp   88      EIGRP           # Enhanced Interior Routing Protocol (Cisco)
ospf    89      OSPFIGP         # Open Shortest Path First IGP
sprite-rpc      90      Sprite-RPC      # Sprite RPC Protocol
larp    91      LARP            # Locus Address Resolution Protocol
mtp     92      MTP             # Multicast Transport Protocol
ax.25   93      AX.25           # AX.25 Frames
ipip    94      IPIP            # Yet Another IP encapsulation
micp    95      MICP            # Mobile Internetworking Control Pro.
scc-sp  96      SCC-SP          # Semaphore Communications Sec. Pro.
etherip 97      ETHERIP         # Ethernet-within-IP Encapsulation
encap   98      ENCAP           # Yet Another IP encapsulation
#       99                      # any private encryption scheme
gmtp    100     GMTP            # GMTP
ifmp    101     IFMP            # Ipsilon Flow Management Protocol
pnni    102     PNNI            # PNNI over IP
pim     103     PIM             # Protocol Independent Multicast
aris    104     ARIS            # ARIS
scps    105     SCPS            # SCPS
qnx     106     QNX             # QNX
a/n     107     A/N             # Active Networks
ipcomp  108     IPComp          # IP Payload Compression Protocol
snp     109     SNP             # Sitara Networks Protocol
compaq-peer     110     Compaq-Peer     # Compaq Peer Protocol
ipx-in-ip       111     IPX-in-IP       # IPX in IP
vrrp    112     VRRP            # Virtual Router Redundancy Protocol
pgm     113     PGM             # PGM Reliable Transport Protocol
#       114                     # any 0-hop protocol
l2tp    115     L2TP            # Layer Two Tunneling Protocol
ddx     116     DDX             # D-II Data Exchange
iatp    117     IATP            # Interactive Agent Transfer Protocol
st      118     ST              # Schedule Transfer
srp     119     SRP             # SpectraLink Radio Protocol
uti     120     UTI             # UTI
smp     121     SMP             # Simple Message Protocol
sm      122     SM              # SM
ptp     123     PTP             # Performance Transparency Protocol
isis    124     ISIS            # ISIS over IPv4
fire    125     FIRE
crtp    126     CRTP            # Combat Radio Transport Protocol
crudp   127     CRUDP           # Combat Radio User Datagram
sscopmce        128     SSCOPMCE
iplt    129     IPLT
sps     130     SPS             # Secure Packet Shield
pipe    131     PIPE            # Private IP Encapsulation within IP
sctp    132     SCTP            # Stream Control Transmission Protocol
fc      133     FC              # Fibre Channel
#       134-254                 # Unassigned
divert  254     DIVERT          # Divert pseudo-protocol [non IANA]
#       255                     # Reserved
alindner@cs215:~$

3. The attempts at a solution (include all code and scripts):
Currently working on
Code:
Question #10

--Working on this...kinda stuck :/


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Keene State College
Keene, NH, USA
Charlie W. CS-215

Last edited by alindner; 04-15-2011 at 12:06 AM.. Reason: Just #10 is left
# 2  
Old 04-14-2011
What kind of data is in /usr/dict/1-1000 and /usr/dict/numbers? I would expect them to contain pretty much the same data. They must be different sinc3e you got question 1 but not question 2. Smilie
# 3  
Old 04-14-2011
Quote:
Originally Posted by Perderabo
What kind of data is in /usr/dict/1-1000 and /usr/dict/numbers? I would expect them to contain pretty much the same data. They must be different sinc3e you got question 1 but not question 2. Smilie
Sorry since i have a few questions im working on i didnt update all the data.
/usr/dict/numbers looks like this
one
two
three
four
five
six
seven
eight
nine
ten
eleven
....up to one thousand

So i could try to form a grep to get the words of even numbers like two, four, six, eight...but run into an issue with fourteen, or things like ten and twenty.

so i wanted to try and grep based on line number but not sure that will work
# 4  
Old 04-15-2011
Regarding problem 10, I am guessing that you are using linux or at least that your grep supports
Quote:
-o, --only-matching
Show only the part of a matching line that matches PATTERN.
Remember that the data starts with a non-# in column 1 and continues with other non-# characters.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Student needs grep command assistance

I am a student in a UNIX/Linux classes having hard time with grep looking for assistance on some home work I need to figure out some kind of grep command to get a out put that only gives me information from a sample file and only list the people with the first name John the sample file is named... (1 Reply)
Discussion started by: jetoutant
1 Replies

2. Shell Programming and Scripting

Assistance required with awk and regular expressions

Hello there, I am trying to get my head around the section below of a script we use that incorporates AWK and Regular Expressions. { match($0,"The broker*");print $1,$2,$3 ":", substr($0, RSTART,RLENGTH)} I have a basic understanding of how match works, what I am struggling with is the... (2 Replies)
Discussion started by: jimbojames
2 Replies

3. UNIX for Dummies Questions & Answers

grep and regular expressions

Hi All, For the past many days I have solved a lot of grep and regular expression questions, Now I am in a search for a good quality set of questions that can help me build and check my knowledge of grep with regular expressions, it would be great if anyone could help me with my requirement. ... (1 Reply)
Discussion started by: rahulkalra9
1 Replies

4. Homework & Coursework Questions

Regular Expressions with GREP

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: Given a text file (big_english.txt) containing roughly 250,000 words, answer the following using grep and... (2 Replies)
Discussion started by: blahblahblah123
2 Replies

5. Shell Programming and Scripting

Assistance to use ls and GREP

Hi We have several folders and subfolders in a heirarchy, representing clients and files we send to them. Files that are not processed are placed in reject folder. I am able to run a LS that will scan all these folders, and ones that show entries (rejected files) are seen here. I am looking for... (8 Replies)
Discussion started by: cdc01
8 Replies

6. Shell Programming and Scripting

Assistence With Using Asterisks in GREP Expressions

I am attempting to find all complete words which contain an asterisk at the beginning and the end - for instance, "*Hello?*" or "*you*". From what I've read, I would have thought that the following expression would do that just fine: \<\*.*\*\> \< denoting the beginning of a word. \*... (12 Replies)
Discussion started by: MagusScythe
12 Replies

7. UNIX for Dummies Questions & Answers

grep and regular expressions :

I wrote a simple korn shell where I am trying to filter all the good record layouts of a file to only leave the bad ones to look at. That file is hudge. Aside from '# comments' and 'var=ssss', all record should follow a specific record layout, with comma seperated fields. Some fields can have any... (2 Replies)
Discussion started by: Browser_ice
2 Replies

8. UNIX for Dummies Questions & Answers

More Grep - Regular Expressions

Hey all! I'm trying to search a file and return all instances of a word, let's say 'foo' in this case, as long as it's not a function name. For example: 1) int foo; //OK 2) //'this is totally fooed up' is also OK 3) int foo (int x, int y) //not ok to return I've tried a lot of regular... (7 Replies)
Discussion started by: Jombee
7 Replies

9. UNIX for Dummies Questions & Answers

grep where expressions reside in file

I have a program that displays many messages on stdout. I have another file that contain error messages only - Each line is a separate message. (msgs.txt) I am trying to show only the errors and not all the output. I tried this but got nothing: myprog | grep < msgs.txt I also tried... (2 Replies)
Discussion started by: GMMike
2 Replies
Login or Register to Ask a Question