1752290 Members
5426 Online
108786 Solutions
New Discussion

char count script

 
SOLVED
Go to solution
Jimmy Roux_1
Advisor

char count script

Do you have a script that will count the number of characters per line of the output of "swlist -l file"?

For example:

Perl5.PERL-MAN: /opt/perl/man/man3/B::Concise.3
Perl5.PERL-MAN: /opt/perl/man/man3/B::Debug.3
Perl5.PERL-MAN: /opt/perl/man/man3/B::Deparse.3
Perl5.PERL-MAN: /opt/perl/man/man3/B::Disassembler.3

The script goes through each line above, disregard the start of each line up to the last "/" character, then count the rest of the characters of each line. If the character count on that line is greater than 30, print the filename and the actual character count.

Thanks,

Jimmy
1 REPLY 1
Masatake Hanayama
Trusted Contributor
Solution

Re: char count script

#/bin/sh
# tested on HP-UX 10.20
swlist -l file | awk -F/ '
{
if (NF > 1) wkstr=$NF
wklen=index(wkstr,"\t")-1
wkstr=substr(wkstr,1,wklen)
if (wklen > 30) printf("%4d %s\n",wklen,wkstr)
}
'