Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching files - Help needed

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I know pretty much nothing about Unix so i'd be grateful if someone could explain to me how i would a) search a file and look for all records within that file with a ( "teleservice code" = "22" )
where the ("totalcalleventduration") not equal to 0
and b) print the record name e.g. CDR2

Check out the example of a record below...

Thanks in advance for any help at all......

-- CDR 2
( MoBasicCallInformation
( SimChargeableSubscriber
( Imsi 0x"234305683001762f")
)
( Destination
( TypeOfNumber 0x"01") -- 1
( NumberingPlan 0x"01") -- 1
( AddressStringDigits 0x"447958879879")
( ModificationIndicator 0x"01") -- 1
)
( CallEventStartTimeStamp
( LocalTimeStamp "20020418224849") -- 0x"323030323034313832323438343
9"
( UtcTimeOffsetCode "A") -- 0x"41", 65
)
( TotalCallEventDuration 0x"00") -- 0
)
( LocationInformation
( NetworkLocation
( RecEntityCode 0x"06") -- 6
( LocationArea 0x"0a96") -- 2710
( CellId 0x"07") -- 7
)
)
( EquipmentInformation
( MobileStationClassMark 0x"04") -- 4
( Imei 0x"3501879055650800")
)
( BasicServiceUsedList
( BasicServiceUsed
( BasicService
( TeleServiceCode "22") -- 0x"3232", 12850
)
( ChargeInformationList
( ChargeInformation
( ChargedItem "E") -- 0x"45", 69
( ExchangeRateCode "A") -- 0x"41", 65
( CallTypeGroup
( CallTypeLevel1 0x"02") -- 2
( CallTypeLevel2 0x"00") -- 0
( CallTypeLevel3 0x"00") -- 0
( CalledCountryCode "44") -- 0x"3434", 13364
)
( ChargeDetailList
( ChargeDetail
( ChargeType "00") -- 0x"3030", 12336
( Charge "W") -- 0x"57", 87
( DayCategory "I") -- 0x"49", 73
( TimeBand "I") -- 0x"49", 73
)
)
)
)
)
)
 
This is really nothing to do with Unix per se.

This is a programming problem, pure and simple. My choice would be Perl ( ) but any language you are comfortable with will work.

You could do this with awk also though with Perl so ubiquitous and so much easier I really wouldn't bother to LEARN awk if I were coming into Unix fresh.


Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
try the following :
grep "teleservice code = "22"" file_to_search | grep -v "totalcalleventduration = 0"
This command will first return all the lines containing teleservice and the remove all the lines for totalcalleventduration Too bad I.T. is not cash business

Luc Foata
Unix sysadmin, Oracle DBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top