Sponsored Content
Top Forums Shell Programming and Scripting Fixed with file- removing leading zeros and adding the space Post 302936428 by mechvijays on Wednesday 25th of February 2015 11:22:29 AM
Old 02-25-2015
Fixed with file- removing leading zeros and adding the space

Hi All,

i have a fixed width file , where each line is 3200 length.

File:

Code:
1ABC 1111 2222 3333 000012341 1001
2ABC 1111 2222 3333 000012342 1002
3ABC 1111 2222 3333 000112343 1003
1DEF 5555 4444 9696 000012344 1004
2DEF 5555 2323 8686 000012345 1005
3DEF 5555 1212 7676 000012346 1006

note: above is the sample the original file line length is 3200

requirement:

output needed:

Code:
1ABC 1111 2222 3333 12341    1001
2ABC 1111 2222 3333 12342    1002
3ABC 1111 2222 3333 112343   1003
1DEF 5555 4444 9696 12344    1004
2DEF 5555 2323 8686 12345    1005
3DEF 5555 1212 7676 12346    1006


requirement:

from the position 21 - 29 ,we need to remove the leading zeros and rpad for 9 characters with space.

The file which we are using is very huge file. so please give command which will run faster.

version used:
SunOS sasbsd27c1 5.10 Generic_150400-10 sun4u sparc SUNW,SPARC-Enterprise

Last edited by Scrutinizer; 02-25-2015 at 01:05 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

truncating leading zeros of a column in a file

Hi I have a file in which I have 5 columns which are delimited by “|” as shown ABC|12|YAK|METRIC|000000019.5 XYZ|10|ABX|META|000000002.5 Now my requirement is to take the last column trim the leading zero's for that column values and write back to the same file in the same... (7 Replies)
Discussion started by: nvuradi
7 Replies

2. Shell Programming and Scripting

Removing leading zeros from a variable

How do I remove or add leading zeroa from a variable. To make variable 10 characters long when adding zeros. (6 Replies)
Discussion started by: toshidas2000
6 Replies

3. Shell Programming and Scripting

Adding Leading Zero with Right Justified and Removing Duplicates

hello everyone. I'm hoping someone can help me out here. I have 2 files. It looks like this: File 1: abc1, defg, 50.00, mno,990 abc2, cats, 100.00, pops,991 abc3, dogs, 1.00, treat,992 File 2: 990, airplanes, runway, doctor 991, jets, birds, much 990,... (13 Replies)
Discussion started by: crazyhpux
13 Replies

4. Shell Programming and Scripting

Help with adding leading zeros to a filename

Hi i need help in adding leading zero to filenames e.g file name in my folder are 1_234sd.txt 23_234sd.txt the output i need is 001_234sd.txt 023_234sd.txt can i do this shell scripting please help (2 Replies)
Discussion started by: rsmpk
2 Replies

5. Shell Programming and Scripting

Removing leading zeros for a decimal column

removing leading zeros for a decimal column in a file which has string & decimal values ,,,,,6630140,XXXXXXXXXXXXXXX, 0020.00,USA ,,,,,6630150,XXXXXXXXXXXXXXXL (xyz, 0010.00,USA ,,,,,6630150,XXXXXXXXXXXXXXX(xyz), 1300.00,USA My file contains 9 columns. Out 9 columns, 8th column contains the... (9 Replies)
Discussion started by: marpadga18
9 Replies

6. UNIX for Dummies Questions & Answers

Add leading zeros to columns in a file

Hello Gurus, Quick question. I have a file with the following records: A~000000000000518000~SLP ~99991231~20090701~88.50~USD~CS~ A~000000000000518000~SLP ~99991231~20090701~102.00~USD~CS~ A~000000000000772000~SLP ~99991231~20100701~118.08~USD~CS~ I wold like to do the following: 1. Add... (1 Reply)
Discussion started by: chumsky
1 Replies

7. Shell Programming and Scripting

Help deleting leading zeros in a file

I have a list of numbers extracted and need to delete the leading zeros from them, but when i do so, the command I am using also deletes numbers that end in Zero as well. eg 10, 20, 30, etc this is part of a larger script and the only way I can think of is to try and detect the 10,20 30 etc in... (19 Replies)
Discussion started by: kcpoole
19 Replies

8. Shell Programming and Scripting

Adding Leading Zeros for date in a file

Hello, I have a pipe separated file with two major lines. One is header and another is detail line. Header starts with H and Detail start with D. Sample Content: H|123456|Joes Watson|UK|4/5/2016|12/5/2016|3456|HC|NW|||||| D|123456|Joes... (13 Replies)
Discussion started by: Mannu2525
13 Replies

9. UNIX for Beginners Questions & Answers

How do I remove leading spaces in UNIX when count of space character is not fixed? Example below-

Script showStreamsGLIS$reg.$env.ksh gives me output as below- Job Stime Etime Status ExitCode GLIS-AS-S-EFL-LOCK-B ----- ----- OI 103313880/0 GLIS-ALL-Q-EOD-FX-UPDT-1730-B ----- ----- TE 0/0 GLIS-TK-S-BWSOD-B ... (8 Replies)
Discussion started by: Tanu
8 Replies

10. Shell Programming and Scripting

Ho to remove leading zeros from a csv file which is sent from a UNIX script

Hi All, I am using a informatica job to create a csv file and a unix script the mail the generated file.Everything is working fine but I am not seeing leading zeros in the csv file sent in the mail.These zeros were present when the .csv file was generated by informatica procees. Is there any... (11 Replies)
Discussion started by: karthik adiga
11 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 04:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy