1827631 Members
3270 Online
109966 Solutions
New Discussion

Max Line Size

 
SOLVED
Go to solution
MAYIANAN
Advisor

Max Line Size

Hi,

How to get the max line size from a unix file??

6 REPLIES 6
Ralf Seefeldt
Valued Contributor

Re: Max Line Size

Hello MAYIANAN,

UNIX files should not have a max linesize.

It always depend on the application, that wants to use the file.

For example, vi can not handle as long lines as vim can.

What are your application?

Bye
Ralf
Dennis Handly
Acclaimed Contributor
Solution

Re: Max Line Size

You can of course use awk to read each line and print the maximum length.
$ awk '
BEGIN { maxlen = 0 }
{
if (maxlen < length($0)
maxlen = length($0)
}
END { print maxlen }' file
Hemmetter
Esteemed Contributor

Re: Max Line Size

Hi,

if you mean the size of longest line of a file:

Linux: $ wc -L our-file
HP: awk ' BEGIN { MAX=0 } { X=length() ; if ( X > MAX ) MAX=X } END { print MAX }' yourfile


hope this helps.
rgds
HGH
MAYIANAN
Advisor

Re: Max Line Size

Thx everybody, its working
MAYIANAN
Advisor

Re: Max Line Size

Thx
Dennis Handly
Acclaimed Contributor

Re: Max Line Size

You have not assigned any points to this thread. Please read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
You can reopen threads with:
http://forums1.itrc.hp.com/service/forums/helptips.do?#41