Sponsored Content
Full Discussion: Character position
Top Forums UNIX for Dummies Questions & Answers Character position Post 87547 by Unbeliever on Tuesday 25th of October 2005 11:56:06 AM
Old 10-25-2005
This following code should me modifyable to your particular circumstances. save it in a file say called 'display.pl', make it executable and run it like

display.pl <your input file>

Code:
#!/usr/local/bin/perl

# read in file
@data=<>;

# determine largest line in file
foreach $data (@data)
{
  $max = length($data) if (length($data) > $max);
}

# how many actual digits in the number
$digits = length($max)+1;

# print out the heading
for ($i=0;$i<$max;$i++)
{
  printf("%${digits}d",$i);
}
print "\n";

# print out the data
foreach $data(@data)
{
  @line=split(//,$data);
  foreach $char (@line)
  {
    printf("%${digits}s",$char);
  }
}
print "\n";

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Counting position of a character

Hi All, I have a file of the format : idsfskjvfdznvdfjvh ierwjfkncmvlkmc xszkmdvnosndzjndf weuhrndzierfncv rndsjnsllshens iernzkfndslkdhf zkinewfinfvlkmvd I wish to count the occurrences of character 'z' in the file. I also need to find out the position of 'z' in various lines. and... (3 Replies)
Discussion started by: rochitsharma
3 Replies

2. Shell Programming and Scripting

URG!! Last position of a character

Hi. If I have files with names like abcd.20080625.1234.abc.XYZ abcd.20080625.1234.abc.XYZW how can I get the XYZ or XYZW part? is there something like an Index() function but in reverse order? I was thinking that if I can get the position of the last dot... (7 Replies)
Discussion started by: mrodrig
7 Replies

3. Shell Programming and Scripting

insert character in particular position.

I want to insert space in 7th position of all the lines usign vi editor or sed command Input file 12345689010 abcdefghijk . . Output file 123456 89010 abcdef ghijk . . (7 Replies)
Discussion started by: Jairaj
7 Replies

4. Shell Programming and Scripting

Identify the position of character

Hi, Can some one guide me to identify the position of a character using index in UNIX. I have a record like "17/11/2010 15:16:39;reject;10.44.48.65;daemon alert; src: 10.44.48.112; dst: 172.21.52.88" . I need to identify the value which comes after _src:_ (_ denotes space). I am able to... (15 Replies)
Discussion started by: suneel.mekala
15 Replies

5. Shell Programming and Scripting

Extract a character specifying position

hi , i am having a file Full_ARTMAS_20110510152425.xml in my local directory. i wanted to extract the character at the 35143546 th position at line 1 of this file.Can any body help me how to do it??? regards Anjali (2 Replies)
Discussion started by: angel12345
2 Replies

6. Shell Programming and Scripting

position of character in a line

i want to find the position of a character in a line , the first position, last, 5th occurence position , i ve tried grep -n , and expr index but they dont fit the bill. Please let me know if there is any other alternative (2 Replies)
Discussion started by: phpsnook
2 Replies

7. Shell Programming and Scripting

Get character position within variable

Hi all let's say i have a file named 1234_v2_abcd i need to find the position of the character located after _v, in above case this would be character number 2 the count of the characters before _v can change, but i always have a number after _v can anybody help :) (4 Replies)
Discussion started by: gigagigosu
4 Replies

8. Shell Programming and Scripting

Find character and Replace character for given position

Hi, i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command. thanks in advance, Sara (9 Replies)
Discussion started by: Sara183
9 Replies

9. Shell Programming and Scripting

Position of character in word

How can I represent the position of 1 (considering only the 1s after the colon) in the word from field5 and above; counting from right to left. Input: TT-124 06-03-14 08-02-10 FAS CAT1:10 TT-125-1 05-03-14 10-06-08 CAS CAT2:1010 FAT1:10000 TT-125-3 07-03-14 11-02-06 FAS FAT1:1101... (6 Replies)
Discussion started by: aydj
6 Replies

10. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies
ldns(3) 						     Library Functions Manual							   ldns(3)

NAME
ldns_wire2rr, ldns_wire2pkt, ldns_wire2rdf, ldns_wire2dname SYNOPSIS
#include <stdint.h> #include <stdbool.h> #include <ldns/ldns.h> ldns_status ldns_wire2rr(ldns_rr **rr, const uint8_t *wire, size_t max, size_t *pos, ldns_pkt_section section); ldns_status ldns_wire2pkt(ldns_pkt **packet, const uint8_t *data, size_t len); ldns_status ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos); ldns_status ldns_wire2dname(ldns_rdf **dname, const uint8_t *wire, size_t max, size_t *pos); DESCRIPTION
ldns_wire2rr() converts the data on the uint8_t bytearray (in wire format) to a DNS resource record. This function will initialize and allocate memory space for the rr structure. The length of the wiredata of this rr is added to the *pos value. rr: pointer to the structure to hold the rdata value wire: pointer to the buffer with the data max: the length of the data buffer (in bytes) pos: the position of the rr in the buffer (ie. the number of bytes from the start of the buffer) section: the section in the packet the rr is meant for Returns LDNS_STATUS_OK if everything succeeds, error otherwise ldns_wire2pkt() converts the data on the uint8_t bytearray (in wire format) to a DNS packet. This function will initialize and allocate memory space for the packet structure. packet: pointer to the structure to hold the packet data: pointer to the buffer with the data len: the length of the data buffer (in bytes) Returns LDNS_STATUS_OK if everything succeeds, error otherwise ldns_wire2rdf() converts the data on the uint8_t bytearray (in wire format) to DNS rdata fields, and adds them to the list of rdfs of the given rr. This function will initialize and allocate memory space for the dname structures. The length of the wiredata of these rdfs is added to the *pos value. All rdfs belonging to the RR are read; the rr should have no rdfs yet. An error is returned if the format cannot be parsed. rr: pointer to the ldns_rr structure to hold the rdata value wire: pointer to the buffer with the data max: the length of the data buffer (in bytes) pos: the position of the rdf in the buffer (ie. the number of bytes from the start of the buffer) Returns LDNS_STATUS_OK if everything succeeds, error otherwise ldns_wire2dname() converts the data on the uint8_t bytearray (in wire format) to a DNS dname rdata field. This function will initialize and allocate memory space for the dname structure. The length of the wiredata of this rdf is added to the *pos value. dname: pointer to the structure to hold the rdata value wire: pointer to the buffer with the data max: the length of the data buffer (in bytes) pos: the position of the rdf in the buffer (ie. the number of bytes from the start of the buffer) Returns LDNS_STATUS_OK if everything succeeds, error otherwise AUTHOR
The ldns team at NLnet Labs. Which consists out of Jelte Jansen and Miek Gieben. REPORTING BUGS
Please report bugs to ldns-team@nlnetlabs.nl or in our bugzilla at http://www.nlnetlabs.nl/bugs/index.html COPYRIGHT
Copyright (c) 2004 - 2006 NLnet Labs. Licensed under the BSD License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
ldns_rr2wire, ldns_pkt2wire, ldns_rdf2wire, ldns_dname2wire. And perldoc Net::DNS, RFC1034, RFC1035, RFC4033, RFC4034 and RFC4035. REMARKS
This manpage was automaticly generated from the ldns source code by use of Doxygen and some perl. 30 May 2006 ldns(3)
All times are GMT -4. The time now is 07:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy