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
Text::Password::Pronounceable(3pm)			User Contributed Perl Documentation			Text::Password::Pronounceable(3pm)

NAME
Text::Password::Pronounceable - Generate pronounceable passwords SYNOPSIS
# Generate a pronounceable password that is between 6 and 10 characters. Text::Password::Pronounceable->generate(6, 10); # Ditto my $pp = Text::Password::Pronounceable->new(6, 10); $pp->generate; DESCRIPTION
This module generates pronuceable passwords, based the the English digraphs by D Edwards. METHODS new $pp = Text::Password::Pronounceable->new($min, $max); $pp = Text::Password::Pronounceable->new($len); Construct a password factory with length limits of $min and $max. Or create a password factory with fixed length if only one argument is provided. generate $pp->generate; $pp->generate($len); $pp->generate($min, $max); Text::Password::Pronounceable->generate($len); Text::Password::Pronounceable->generate($min, $max); Generate password. If used as an instance method, arguments override the factory settings. HISTORY
This code derived from mpw.pl, a bit of code with a sordid history. o CPAN module by Chia-liang Kao 9/11/2006. o Perl cleaned up a bit by Jesse Vincent 1/14/2001. o Converted to perl from C by Marc Horowitz, 1/20/2000. o Converted to C from Multics PL/I by Bill Sommerfeld, 4/21/86. o Original PL/I version provided by Jerry Saltzer. LICENSE
Copyright 2006 by Best Practical Solutions, LLC. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.10.1 2010-08-16 Text::Password::Pronounceable(3pm)
All times are GMT -4. The time now is 12:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy