Sponsored Content
Top Forums Shell Programming and Scripting Perl- Finding average "frequency" of occurrence of duplicate lines Post 302545620 by yazu on Tuesday 9th of August 2011 02:48:58 AM
Old 08-09-2011
Ok. Is this algorithm is right (there is 1 second difference between lines)?
Code:
cat INPUTFILE 
1301892853.870 a
1301892854.870 b
1301892855.870 a
1301892856.870 c
1301892857.870 b
1301892858.870 a
1301892859.870 a
1301892860.870 d
1301892861.870 d
 
perl -ane '
  push @{$seen{$F[1]}}, $F[0];
  END {
    for $key (sort keys %seen) {
      @ts = @{$seen{$key}};
      $n = @ts;      
      $prev = $ts[0];
      $nt = 0;
      print "$key $n ";
      for $time (@ts) {
        $nt += $time - $prev;
      }
      print $nt/$n, "\n";
    }
  }
' INPUTFILE
a 4 3.25
b 2 1.5
c 1 0
d 2 0.5


Last edited by yazu; 08-09-2011 at 03:59 AM.. Reason: small improvements
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

3. Solaris

"Load Average" vs "virtual processor"

Hi, I have one question regarding the understanding of “load average” in a platform with virtual processors. Suppose in this situation: Total number of physical processors: 1 Number of virtual processors: 32 Total number of cores: 4 Number of cores per physical... (1 Reply)
Discussion started by: MDING
1 Replies

4. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

5. Shell Programming and Scripting

Cant get awk 1liner to remove duplicate lines from Delimited file, get "event not found" error..help

Hi, I am on a Solaris8 machine If someone can help me with adjusting this awk 1 liner (turning it into a real awkscript) to get by this "event not found error" ...or Present Perl solution code that works for Perl5.8 in the csh shell ...that would be great. ****************** ... (3 Replies)
Discussion started by: andy b
3 Replies

6. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
iconv(5)						Standards, Environments, and Macros						  iconv(5)

NAME
iconv - code set conversion tables DESCRIPTION
The following code set conversions are supported: Code Set Conversions Supported Code Symbol Target Code Symbol Target Output ISO 646 646 ISO 8859-1 8859 US ASCII ISO 646de 646de ISO 8859-1 8859 German ISO 646da 646da ISO 8859-1 8859 Danish ISO 646en 646en ISO 8859-1 8859 English ASCII ISO 646es 646es ISO 8859-1 8859 Spanish ISO 646fr 646fr ISO 8859-1 8859 French ISO 646it 646it ISO 8859-1 8859 Italian ISO 646sv 646sv ISO 8859-1 8859 Swedish ISO 8859-1 8859 ISO 646 646 7 bit ASCII ISO 8859-1 8859 ISO 646de 646de German ISO 8859-1 8859 ISO 646da 646da Danish ISO 8859-1 8859 ISO 646en 646en English ASCII ISO 8859-1 8859 ISO 646es 646es Spanish ISO 8859-1 8859 ISO 646fr 646fr French ISO 8859-1 8859 ISO 646it 646it Italian ISO 8859-1 8859 ISO 646sv 646sv Swedish ISO 8859-16 iso16 ISO 8859-2 iso2 ISO Latin 2 ISO 8859-2 iso2 ISO 8859-16 iso16 ISO Latin 10 ISO 8859-16 iso16 IBM 850 ibm850 IBM 850 code page ISO 8859-16 iso16 IBM 870 ibm870 IBM 870 code page ISO 8859-2 iso2 MS 1250 win2 Windows Latin 2 ISO 8859-2 iso2 MS 852 dos2 MS-DOS Latin 2 ISO 8859-2 iso2 Mazovia maz Mazovia IBM 850 ibm850 ISO 8859-16 iso16 ISO Latin 10 IBM 870 ibm870 ISO 8859-16 iso16 ISO Latin 10 MS 1250 win2 DHN dhn Dom Handlowy Nauki MS 852 dos2 ISO 8859-2 iso2 ISO Latin 2 MS 852 dos2 MS 1250 win2 Windows Latin 2 MS 852 dos2 Mazovia maz Mazovia MS 852 dos2 DHN dhn Dom Handlowy Nauki Mazovia maz ISO 8859-2 iso2 ISO Latin 2 Mazovia maz MS 1250 win2 Windows Latin 2 Mazovia maz MS 852 dos2 MS-DOS Latin 2 Mazovia maz DHN dhn Dom Handlowy Nauki DHN dhn ISO 8859-2 iso2 ISO Latin 2 DHN dhn MS 1250 win2 Windows Latin 2 DHN dhn MS 852 dos2 MS-DOS Latin 2 DHN dhn Mazovia maz Mazovia ISO 8859-5 iso5 KOI8-R koi8 KOI8-R ISO 8859-5 iso5 PC Cyrillic alt Alternative PC Cyrillic ISO 8859-5 iso5 MS 1251 win5 Windows Cyrillic ISO 8859-5 iso5 Mac Cyrillic mac Macintosh Cyrillic KOI8-R koi8 ISO 8859-5 iso5 ISO 8859-5 Cyrillic KOI8-R koi8 PC Cyrillic alt Alternative PC Cyrillic KOI8-R koi8 MS 1251 win5 Windows Cyrillic KOI8-R koi8 Mac Cyrillic mac Macintosh Cyrillic PC Cyrillic alt ISO 8859-5 iso5 ISO 8859-5 Cyrillic PC Cyrillic alt KOI8-R koi8 KOI8-R PC Cyrillic alt MS 1251 win5 Windows Cyrillic PC Cyrillic alt Mac Cyrillic mac Macintosh Cyrillic MS 1251 win5 ISO 8859-5 iso5 ISO 8859-5 Cyrillic MS 1251 win5 KOI8-R koi8 KOI8-R MS 1251 win5 PC Cyrillic alt Alternative PC Cyrillic MS 1251 win5 Mac Cyrillic mac Macintosh Cyrillic Mac Cyrillic mac ISO 8859-5 iso5 ISO 8859-5 Cyrillic Mac Cyrillic mac KOI8-R koi8 KOI8-R Mac Cyrillic mac PC Cyrillic alt Alternative PC Cyrillic Mac Cyrillic mac MS 1251 win5 Windows Cyrillic CONVERSIONS
The conversions are performed according to the tables contained in the manual pages cross-referenced in the Index of Conversion Code Tables below. +--------------------------------+---------------------+--------------------+ |Index of Conversion Code Tables | | | +--------------------------------+---------------------+--------------------+ |Code | Target Code |See Manual Page | +--------------------------------+---------------------+--------------------+ |ISO 646 | ISO 8859-1 |iconv_646(5) | +--------------------------------+---------------------+--------------------+ |ISO 646de | ISO 8859-1 | | +--------------------------------+---------------------+--------------------+ |ISO 646da | ISO 8859-1 | | +--------------------------------+---------------------+--------------------+ |ISO 646en | ISO 8859-1 | | +--------------------------------+---------------------+--------------------+ |ISO 646es | ISO 8859-1 | | +--------------------------------+---------------------+--------------------+ |ISO 646fr | ISO 8859-1 | | +--------------------------------+---------------------+--------------------+ |ISO 646it | ISO 8859-1 | | +--------------------------------+---------------------+--------------------+ |ISO 646sv | ISO 8859-1 | | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646 |iconv_8859-1(5) | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646de | | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646da | | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646en | | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646es | | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646fr | | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646it | | +--------------------------------+---------------------+--------------------+ |ISO 8859-1 | ISO 646sv | | +--------------------------------+---------------------+--------------------+ |ISO 8859-2 | MS 1250 |iconv_8859-2(5) | +--------------------------------+---------------------+--------------------+ |ISO 8859-2 | MS 852 | | +--------------------------------+---------------------+--------------------+ |ISO 8859-2 | Mazovia | | +--------------------------------+---------------------+--------------------+ |ISO 8859-2 | DHN | | +--------------------------------+---------------------+--------------------+ |MS 1250 | ISO 8859-2 |iconv_1250(5) | +--------------------------------+---------------------+--------------------+ |MS 1250 | MS 852 | | +--------------------------------+---------------------+--------------------+ |MS 1250 | Mazovia | | +--------------------------------+---------------------+--------------------+ |MS 1250 | DHN | | +--------------------------------+---------------------+--------------------+ |MS 852 | ISO 8859-2 |iconv_852(5) | +--------------------------------+---------------------+--------------------+ |MS 852 | MS 1250 | | +--------------------------------+---------------------+--------------------+ |MS 852 | Mazovia | | +--------------------------------+---------------------+--------------------+ |MS 852 | DHN | | +--------------------------------+---------------------+--------------------+ |Mazovia | ISO 8859-2 |iconv_maz(5) | +--------------------------------+---------------------+--------------------+ |Mazovia | MS 1250 | | +--------------------------------+---------------------+--------------------+ |Mazovia | MS 852 | | +--------------------------------+---------------------+--------------------+ |Mazovia | DHN | | +--------------------------------+---------------------+--------------------+ +--------------------------------+---------------------+--------------------+ |Index of Conversion Code Tables | | | +--------------------------------+---------------------+--------------------+ |Code | Target Code |See Manual Page | +--------------------------------+---------------------+--------------------+ |DHN | ISO 8859-2 | iconv_dhn(5) | +--------------------------------+---------------------+--------------------+ |DHN | MS 1250 | | +--------------------------------+---------------------+--------------------+ |DHN | MS 852 | | +--------------------------------+---------------------+--------------------+ |DHN | Mazovia | | +--------------------------------+---------------------+--------------------+ |ISO 8859-5 | KOI8-R | iconv_8859-5(5) | +--------------------------------+---------------------+--------------------+ |ISO 8859-5 | PC Cyrillic | | +--------------------------------+---------------------+--------------------+ |ISO 8859-5 | MS 1251 | | +--------------------------------+---------------------+--------------------+ |ISO 8859-5 | Mac Cyrillic | | +--------------------------------+---------------------+--------------------+ |KOI8-R | ISO 8859-5 |iconv_koi8-r(5) | +--------------------------------+---------------------+--------------------+ |KOI8-R | PC Cyrillic | | +--------------------------------+---------------------+--------------------+ |KOI8-R | MS 1251 | | +--------------------------------+---------------------+--------------------+ |KOI8-R | Mac Cyrillic | | +--------------------------------+---------------------+--------------------+ |PC Cyrillic | ISO 8859-5 |iconv_pc_cyr(5) | +--------------------------------+---------------------+--------------------+ |PC Cyrillic | KOI8-R | | +--------------------------------+---------------------+--------------------+ |PC Cyrillic | MS 1251 | | +--------------------------------+---------------------+--------------------+ |PC Cyrillic | Mac Cyrillic | | +--------------------------------+---------------------+--------------------+ |MS 1251 | ISO 8859-5 |iconv_1251(5) | +--------------------------------+---------------------+--------------------+ |MS 1251 | KOI8-R | | +--------------------------------+---------------------+--------------------+ |MS 1251 | PC Cyrillic | | +--------------------------------+---------------------+--------------------+ |MS 1251 | Mac Cyrillic | | +--------------------------------+---------------------+--------------------+ |Mac Cyrillic | ISO 8859-5 |iconv_mac_cyr(5) | +--------------------------------+---------------------+--------------------+ |Mac Cyrillic | KOI8-R | | +--------------------------------+---------------------+--------------------+ |Mac Cyrillic | PC Cyrillic | | +--------------------------------+---------------------+--------------------+ |Mac Cyrillic | MS 1251 | | +--------------------------------+---------------------+--------------------+ FILES
/usr/lib/iconv/*.so conversion modules /usr/lib/iconv/*.t Conversion tables. /usr/lib/iconv/geniconvtbl/binarytables/*.bt Conversion binary tables. /usr/lib/iconv/iconv_data List of conversions supported by conversion tables. SEE ALSO
iconv(1), iconv(3C), iconv_1250(5), iconv_1251(5), iconv_646(5), iconv_852(5), iconv_8859-1(5), iconv_8859-2(5), iconv_8859-5(5), iconv_dhn(5), iconv_koi8-r(5), iconv_mac_cyr(5), iconv_maz(5), iconv_pc_cyr(5), iconv_unicode(5) SunOS 5.11 5 Dec 2001 iconv(5)
All times are GMT -4. The time now is 04:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy