Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Performance issue to read line by line Post 302972406 by Scrutinizer on Thursday 5th of May 2016 02:43:33 AM
Old 05-05-2016
In addition, it will not matter much performance-wise, but the function could be further reduced to something like this, making it a bit easier to understand and thus more maintainable.

Code:
process_each_record() {
  ###### extract first four characters  ##############
  case $1 in
    (1111*)     a1=100; a2=0; a3=0; a4=0; a5=0; a6=0; a7=0; a8=0; a9=0   ;;
    (1112*)     a2=$((a2+1)); a3=$((a3+2))                               ;;
    (1113*)     a5=$((a5+3)); a7=$((a7+1))                               ;;
    (1114*)     a4=$((a4+3)); a6=$((a6+4))                               ;;
    (1115*)     a7=$((a7+1)); a9=$((a9+3))                               ;;
    (1116*)     a5=$((a5+1)); a8=$((a8+1))                               ;;
    (2221*)     a6=0;   a7=0; a8=0;   a9=0                               ;;
    (2222*)     a3=$((a3+1)); a7=$((a7+3))                               ;;
    (3333*)     a8=$((a8+1)); a9=$((a9+5))                               ;;
    (5555*)     a1=$((a1+1)); a2=$((a2+3)); a3=$((a3+1)); a4=$((a4+1))   ;;
  esac
  echo "${line_no}${a1}${a2}${a3}${a4}${a5}${a6}${a7}${a8}${a9}${1}"
}


Last edited by Scrutinizer; 05-05-2016 at 03:56 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

2. Shell Programming and Scripting

While loop read line Issue

Hi I am using while loop, below, to read lines from a very large file, around 400,000 rows. The script works fine until around line 300k but then starts giving incorrect result. I have tried running the script with a smaller data set and it works fine. I made sure to include the line where... (2 Replies)
Discussion started by: saurabhkumar198
2 Replies

3. Shell Programming and Scripting

Multi Line 'While Read' command issue when using sh -c

Hi, I'm trying to run the following command using sh -c ie sh -c "while read EachLine do rm -f $EachLine ; done < file_list.lst;" It doesn't seem to do anything. When I run this at the command line, it does remove the files contained in the list so i know the command works ie... (4 Replies)
Discussion started by: chrispward
4 Replies

4. Shell Programming and Scripting

while read LINE issue

Hi, This is the script and the error I am receiving Can anyone please suggest ? For the exmaple below assume we are using vg01 #!/bin/ksh echo "##### Max Mount Count Fixer #####" echo "Please insert Volume Group name to check" read VG lvs |grep $VG | awk {'print $1'} > /tmp/audit.log ... (2 Replies)
Discussion started by: galuzan
2 Replies

5. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

6. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

7. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

8. Shell Programming and Scripting

Read line, issue with leading - and {}'s

Heyas With my forum search term 'issue with leading dash' i found 2 closed threads which sadly didnt help me. Also me was to eager to add the script, that i didnt properly test, and just now figured this issue. So i have this code: if ] then while read line do line="${line/-/'\-'}"... (7 Replies)
Discussion started by: sea
7 Replies

9. Shell Programming and Scripting

[BASH] read 'line' issue with leading tabs and virtual line breaks

Heyas I'm trying to read/display a file its content and put borders around it (tui-cat / tui-cat -t(ypwriter). The typewriter-part is a 'bonus' but still has its own flaws, but thats for later. So in some way, i'm trying to rewrite cat using bash and other commands. But sadly it fails on... (2 Replies)
Discussion started by: sea
2 Replies

10. Shell Programming and Scripting

Performance issue - to read line by line

All- We have a performance issue in reading a file line by line. Please find attached scripts for the same. Currently it is taking some 45 min to parse "512444" lines. Could you please have a look at it and provide any suggestions to improve the performance. Thanks, Balu ... (12 Replies)
Discussion started by: balu1729
12 Replies
ram_monitor(1M) 														   ram_monitor(1M)

NAME
ram_monitor - the Route Administration Manager (RAM) monitor SYNOPSIS
[IP_address] CLI_Port_Number DESCRIPTION
is an interactive command line utility used to query routing protocol daemons ripngd(1M), bgpd(1M), and isisd(1M). can be used to view detailed information on the IO statistics, the error logs, the routing table, the configured protocol interfaces, and the configured filter policies. establishes a TCP connection to the routing daemon through the IP address specified at startup. If an IP address is not specified, con- nects to the routing protocol daemon running on the local machine. Commands In the interactive mode, displays one of the following prompt: When connected to the local machine. When connected to the IP address specified. The can be or Any of the interactive commands can be run at this prompt. The interactive commands can be interrupted at any time via a key- board interrupt. General Commands Displays all local commands and their functions. Displays the list of commands available in the current mode, if command is not specified. If the command name is specified, the help topic corresponding to the specified command is displayed. Displays the history of commands executed in the interactive session. Executes the previous command. Executes the command specified by command number, command_num, in the history of commands. Redirects the command output to the specified file. Exits RIPng-Specific Commands The following are valid RIPng-specific command: Displays the filters configured for RIPng. All the gateway filters are displayed. All the route filters are displayed. By default, both gateway and route filters are displayed. Displays the RIPng routing table. Requests the routing table of the gateway using RIPng's protocol request. destination specifies the gateway address to which the request has to be sent. The option specifies the wait time in seconds for the responses. The default value is 5 seconds if is not specified. Toggles the tracing of the protocol daemon. Displays the RIPng protocol statistics. Displays the RIPng Error counters. Displays the RIPng interface configuration. Displays configured profiles of RIPng. BGP-Specific Commands The following are valid BGP-specific commands: Displays the list of BGP route filters. Displays the BGP routing table. Toggles the tracing of the protocol daemon. Displays the BGP protocol statistics. Displays the list of notification sent to peers. Displays the list of BGP peers. Displays the list of BGP FSM transition events for all peers. IS-IS-Specific Commands The following are IS-IS-specific commands: Displays the adjacency information. Displays the information on interfaces. Displays the LSP database for L1, L2, and L1/L2. Displays statistics. Displays the list of cumulative event log. Displays the list of cumulative errors. Displays the next hop list derived from the SPF calculation. Toggles the trace. Displays the list of configured summary filters. EXAMPLES
RIPng Examples To invoke and connect to type the following at the HP-UX command prompt: Following is sample output of the commands: ripng> show interface If : lan0 Status : UP, ENABLED Profile : 0 Cost : 1 Mtu : 1500 Primary Address : fe80::230:6eff:fe2c:b619 Site Local Access : allow Route Filter Access : deny ripng> show route 5511::230:6eff:fe2c:b619/64 5511::230:6eff:fe2c:b619 1 local lan0 5555::230:6eff:fe2c:b619/64 5555::230:6eff:fe2c:b619 1 local lan0 6666::230:6eff:fe2c:b619/64 6666::230:6eff:fe2c:b619 1 local lan0 ripng> show profile Profile id - 0 Horizon (2 - split/ 3 - poison reverse) : 3 Route Age (in sec) : 180 Periodic Update Timer Interval (in sec) : 30 Triggered Update Timer Interval (in sec) : 5 Garbage Collection Timer Interval (in sec) : 120 Profile id - 1 Horizon (2 - split/ 3 - poison reverse) : 3 Route Age (in sec) : 180 Periodic Update Timer Interval (in sec) : 50 Triggered Update Timer Interval (in sec) : 5 Garbage Collection Timer Interval (in sec) : 120 ripng> show log If : lan0 In Messages : 2 Out Messages : 6 Discarded Messages : 2 RIPng In Requests : 0 RIPng In Responses : 2 RIPng Out Requests : 0 RIPng Out Responses : 6 Unknown Commands : 0 Invalid Version : 0 Total Trig Upd sent : 4 ripng> show error If : lan0 Discarded Messages : 10 Unknown Commands : 0 Invalid Version : 0 Martian Discards : 0 Ripin Discards : 0 Ripout Discards : 0 Route Filter Discards : 0 Trusted Gateway Discards : 0 Import Discards : 0 BGP Examples To invoke and connect to type the following at the HP-UX command prompt: Following is sample output of the commands: bgp> show Command making ambiguity Available commands : [Syntax] : show peers [Syntax] : show eventlog [Syntax] : show filter [Syntax] : show route [Syntax] : show log [Syntax] : show error bgp> show peers No.of peers configured:2 ===================================== BGP neighbor is 4222::1112, remote AS 700, internal link BGP version 4, remote router ID 10.4.7.192 BGP state = Established, up for 51 seconds Rcvd update before 51 secs, hold time is 120 secs, keepalive interval is 40 secs Received 19 messages, 14 Updates Sent 13 messages, 8 Updates Minimum time between advertisement runs is 15 seconds Peer Preference: 0 Peer Related to NONE Group Peer Capability type MP for IPV6 Peer Connection type: ACTIVE Peer Authentication type: MD5 Local host: 4222::1111, Local port: 179 Foreign host: 4222::1112, Foreign port: 64180 No Peer Gateway BGP neighbor is 6222::1111, remote AS 800, external link BGP version 0, remote router ID 0.0.0.0 BGP state = Idle Rcvd update before 0 secs, hold time is 180 secs, keepalive interval is 60 secs Received 0 messages, 0 Updates Sent 0 messages, 0 Updates Minimum time between advertisement runs is 15 seconds Peer Preference: 0 Peer Related to NONE Group Peer Capability type NONE for NONE Peer Connection type: ACTIVE Peer Authentication type: MD5 Local host: 6222::1112, Local port: 0 Foreign host: 6222::1111, Foreign port: 0 No Peer Gateway bgp> show route IPV6 BGP ROUTE TABLE No.of Routes configured:25 ORIGIN: I-IGP, E-EGP, ?-INCOMPLETE ===================================================================== Dest/PrefixLength Nexthop Metric Protocol LP Origin ===================================================================== ::/96 4222::1112 0 bgp 300 I 1666::/64 4222::1112 0 bgp 300 I 2111::/24 4222::1112 0 bgp 300 I 2222::/64 2222::2 0 local 300 I 3111::/24 4222::1112 0 bgp 300 I 4222::/64 4222::1111 0 local 300 I 4333::/64 4333::230:6eff:fe2c:b619 0 local 300 I 5511::/64 5511::1112 0 local 300 I 5555::/64 5555::230:6eff:fe2c:b619 0 local 300 I 5599::/64 5599::230:6eff:fe2c:b619 0 local 300 I 6666::/64 6666::230:6eff:fe2c:b619 0 local 300 I bgp> show filter BGP FILTER INFORMATION No.of Filters Configured:2 ================================================================= FilterName ASNO RP ASP DIR ACTION ================================================================= filter1 100 3333::2222 12,3,4 OUT DENY filter1 100 3333::2222 12,3,4 OUT DENY bgp> show eventlog BGP PEER EVENT LOG INFORMATION BGP neighbor is 4222::1112, remote AS 700, internal link BGP peer state = Established, up for 51 seconds No.of FSM Transitions = 1 FSM Transition History = idle,connect,connect,opensent,active, opensent,openconfirm,established BGP PEER EVENT LOG INFORMATION BGP neighbor is 6222::1111, remote AS 800, external link BGP peer state = Idle No.of FSM Transitions = 0 FSM Transition History = bgp> show error BGP PEER ERROR INFORMATION BGP neighbor is 4222::1112, remote AS 700, internal link Last Error Received NONE Last Error Subcode Received NONE Last Error Sent NONE Last Error Subcode Sent NONE BGP PEER ERROR INFORMATION BGP neighbor is 6222::1111, remote AS 800, external link Last Error Received NONE Last Error Subcode Received NONE Last Error Sent NONE Last Error Subcode Sent NONE bgp> show log BGP PEER LOG INFORMATION BGP neighbor is 4222::1112, remote AS 700, internal link Received 20 messages, 14 Updates Sent 14 messages, 8 Updates BGP PEER LOG INFORMATION BGP neighbor is 6222::1111, remote AS 800, external link Received 0 messages, 0 Updates Sent 0 messages, 0 Updates IS-IS Example To invoke and connect to type the following at the HP-UX command prompt: Following is sample output of the commands: isis> show adj IS-IS Adjacency Table: Sysid Ckt Stte Nbr Usg Hold Pri SNPA IPAddr 00000000000101 2 UP l2 l2 12336 32 112233445566 :: IS-IS Adjacency Count Table: Ckt Ckt Idx Adj Count lan1 2 1 isis> show eventlog EVENTS LOGGED ---------------------------------------------------- ISIS_EVT_DIS_CHANGE : EventID:55;CktLvl:2;CktIdx:2;PrevDIS: 0a.0b.01.02.03.04.02;CurrDIS:00.00.00.00.00.01.01 ISIS_EVT_ADJ_CHANGE : EventID:52;Status:0;AdjType:2;AdjIdx: 1;AdjUsage:2;CktIdx:2;MetType:0;Met:10;AdjSysID:00.00.00.00.00.01 ISIS_EVT_IP_IF_ADDR_CHANGE : EventID:42;Status:0;IfIdx:2; IPAddr31.11.00.00.00.00.00.00.00.00.00.00.00.00.11.11 ISIS_EVT_IP_IF_ADDR_CHANGE : EventID:42;Status:0;IfIdx:2; IPAddrfe.c0.00.00.00.00.00.00.00.00.00.00.00.00.11.11 ISIS_EVT_IP_IF_ADDR_CHANGE : EventID:42;Status:0;IfIdx:2; IPAddr21.11.00.00.00.00.00.00.00.00.00.00.00.00.11.11 ISIS_EVT_IP_IF_ADDR_CHANGE : EventID:42;Status:0;IfIdx:2; IPAddrfe.80.00.00.00.00.00.00.02.30.6e.ff.fe.38.0d.b8 ISIS_EVT_CKT_CHANGE : EventID:51;Status:1;CktType:1;CktLvl:2; MetType:0;Met:0;CktIdx:2 ISIS_EVT_IS_UP : EventID:35;SysID:0a.0b.01.02.03.04 isis> show error SYSTEM Level Errors No. of PDUs dropped : 0 No. of corrupted LSPs : 0 No. of times L1 LSPs database overloaded : 0 No. of times L2 LSPs database overloaded : 0 No. of times manual addr dropped from area : 0 No. of times IS has attempted to exceed MSN: 0 No. of times sequence no (SN) skip occurred: 0 No. of times zero-aged copy of the systems own LSP is received from other IS : 0 No. of Sys Id len mismatch : 0 No. of Max area addresses mismatched : 0 No. of times PDU authentication failed : 0 No. of partition changes occurred : 0 No. of Area mismatches : 0 Errors stats Ckt : lan1 [2] No. of Init failures in this ckt : 0 No. of Times Adjacency rejected : 0 No. of ctrl PDUs Id len mismatch : 0 isis> show lsp 2 IS-IS Level 2 LSP Database: LSPID SeqNo RLT PduLen ChkSum P/ATT/OL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0a0b01020304.00-00 0x00000001 1200 0x0039 0xb410 0/0/0 origLSPBufferSize : 0X05D4 Protocol Supported : IPv6 Area Address : 49:00:01 Authentication Info: passwd=DomainPassword 0a0b01020304.00-01 0x00000001 1200 0x0077 0x6f10 0/0/0 IS Adjacency : 0a:0b:01:02:03:04:02, Metrics: Def 10 IPv6 IF Address : 2111::1111 IPv6 IF Address : 3111::1111 IPv6 IF Address : fec0::1111 IPv6 Reachability : 7711::/24, metric 14, up Authentication Info: passwd=DomainPassword 0a0b01020304.02-00 0x00000002 1200 0x002f 0x46b7 0/0/0 Protocol Supported : IPv6 Authentication Info: passwd=DomainPassword 0a0b01020304.02-01 0x00000002 1200 0x0045 0x1bb9 0/0/0 IS Adjacency : 0a:0b:01:02:03:04:00, Metrics: Def 0 IS Adjacency : 00:00:00:00:00:01:00, Metrics: Def 0 Authentication Info: passwd=DomainPassword isis> show interface ISIS Circuit Table: Name IfId Lvl Address Type Flag Mtu SNPA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lan1 2 1-2 fe80::230:6eff:fe2d:ec50 BC US 1500 00306e2dec50 ISIS Circuit Level Table: Name Lvl PSNP CSNP ReTx HeInt DRHeI HeMul Met Pri DIS-ID ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lan1 1 2 10 30 3000 1 10 127 255 0a0b0102030402 lan1 2 2 10 30 3000 1 10 127 255 0a0b0102030402 isis> show route IS-IS Level 1 Routing Table: Dest GW Met Prf Flag IfId ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5555::1111/64 :: 8 0 D IS -1 7733::/64 fe80::fe13 16 0 D IS 2 Number of routes in Level1 : 2 IS-IS Summary Address Table: SumAddr Metric Filter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5555::1111/24 10 Deny isis> show log Input/Output stats on Ckt :lan1 [2] ISIS LEVEL-1 packets stats Hello PDUs Rx : 0 Tx : 0 Link State PDUs Rx : 0 Tx : 0 CSN PDUs Rx : 0 Tx : 0 PSN PDUs Rx : 0 Tx : 0 ISIS LEVEL-2 packets stats Hello PDUs Rx : 1 Tx : 13 Link State PDUs Rx : 0 Tx : 2 CSN PDUs Rx : 0 Tx : 0 PSN PDUs Rx : 0 Tx : 0 Interface stats on Ckt : lan1 [2] No. of adjacencies state changes : 1 No. of Init failures in this ckt : 0 No. of ISHs sent to peer nodes : 0 No. of ISHs recvd to peer nodes : 0 No. of Times Adjacency rejected : 0 No. of ISIS PDUs sent on this ckt : 2 No. of ISIS PDUs recvd on this ckt : 0 No. of ctrl PDUs Id len mismatch : 0 AUTHOR
was developed by Future Software Ltd. SEE ALSO
bgpd(1M), isisd(1M), ramd(1M), ripngd(1M), rdc(1M), ramd.conf(4). ram_monitor(1M)
All times are GMT -4. The time now is 03:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy