Hello,
I need some help trying to grep from a specific point in a file(part of a name) up until another name. I want to grab anything containing segment "what ever the user chooses to input" up until the statistics portion of the file and place these in another file. I also need these to stay in the same order as the orginal file. The file that I am grep'ing through is pasted below. The only difference is the original has thousands of these segments in it.
I can only grep out specific file names, any other variation I've tried gives me everything listed in the file.
}
segment "THIS" {
agentAddress "111.111.111.111"
uniqueDeviceId "11:11:11:11:11:11"
mibTranslationFile "asdfasdfasdfasdf.mtf"
index "9"
statistics "1"
deviceSpeed "10000000.0"
discoverMtf "asdfasdf.mtf"
sysDescr "Cisco Systems Catalyst 1900"
sysName "yadayada"
sysLoc "12345 wilshire"
sysContact "Joe Schmoe"
ifDescr "1 "
ifType "asdfasdfasdfasdf"
nmsName "asdfasdfasdfasdf"
enterpriseId "9"
ifPhysAddress "asdfasdfasdf"
community "asdfadsf"
}
segment "That" {
agentAddress "111.111.111.111"
uniqueDeviceId "11:11:11:11:11:11"
mibTranslationFile "asdfasdfasdfasdf.mtf"
index "9"
statistics "1"
deviceSpeed "10000000.0"
discoverMtf "asdfasdf.mtf"
sysDescr "Cisco Systems Catalyst 1900"
sysName "yadayada"
sysLoc "12345 wilshire"
sysContact "Joe Schmoe"
ifDescr "1 "
ifType "asdfasdfasdfasdf"
nmsName "asdfasdfasdfasdf"
enterpriseId "9"
ifPhysAddress "asdfasdfasdf"
community "asdfadsf"
}
segment "blah_blah" {
agentAddress "111.111.111.111"
uniqueDeviceId "11:11:11:11:11:11"
mibTranslationFile "asdfasdfasdfasdf.mtf"
index "9"
statistics "1"
deviceSpeed "10000000.0"
discoverMtf "asdfasdf.mtf"
sysDescr "Cisco Systems Catalyst 1900"
sysName "yadayada"
sysLoc "12345 wilshire"
sysContact "Joe Schmoe"
ifDescr "1 "
ifType "asdfasdfasdfasdf"
nmsName "asdfasdfasdfasdf"
enterpriseId "9"
ifPhysAddress "asdfasdfasdf"
community "asdfadsf"
}
Thanks in advance,
Kasparaitis