Sponsored Content
Top Forums Shell Programming and Scripting Find the length of the longest line Post 302143752 by panknil on Saturday 3rd of November 2007 05:20:40 AM
Old 11-03-2007
Find the length of the longest line

Dear All,

To find the length of the longest line from a file i have used wc -L which is giving the proper output...

But the problem is AIX os does not support wc -L command.
so is there any other way 2 to find out the length of the longest line using awk or sed ?

Regards,
Pankaj
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

2. Shell Programming and Scripting

Shell script to find longest phrase

Hi Everyone, I am trying to write a shell script that can find the longest phrase that appears at least twice in an online news article. The HTML has been parsed through an HTML parser, converted to XML and the article content extracted. I have put this article content in a text file to work... (24 Replies)
Discussion started by: stargazerr
24 Replies

3. Shell Programming and Scripting

Bash script find longest line/lines in several files

Hello everyone... I need to find out, how to find longest line or possibly lines in several files which are arguments for script. The thing is, that I tried some possibilities before, but nothing worked correctly. Example when i use: awk ' { if ( length > L ) { L=length ;s=$0 } }END{ print... (23 Replies)
Discussion started by: 1tempus1
23 Replies

4. Shell Programming and Scripting

Find the length of each line in the file

Hi, I want to find the length of each line(including all the characters, spaces etc.) in a file and check if all the lines are of same length using a ksh script. Please help. Thanks in advance. (7 Replies)
Discussion started by: Suryaaravindh
7 Replies

5. Shell Programming and Scripting

Find longest string and print it

Hello all, I need to find the longest string in a select field and print that field. I have tried a few different methods and I always end up one step from where I need to be. Methods thus far: nawk '{if (length($1) > long) long=length($1); if(length($1)==long) print $1}' The above... (6 Replies)
Discussion started by: SEinT
6 Replies

6. UNIX for Dummies Questions & Answers

Display all the words whose length is equal to the longest word in the text

Hi Guys, I was going some trial and error to see if I can find the longest word in a text. I was using Pipes because they are easier to use in this case. I was stuck on this for a while so I thought I'll get some help with it. I tried this code to separate all the words in a text in... (4 Replies)
Discussion started by: bawse.c
4 Replies

7. Shell Programming and Scripting

Longest length of string in array

I would be grateful if someone could help me. I am trying to write a .sh script in UNIX. I have the following code; User=john User=james User=ian User=martin for x in ${User} do print ${#x} done This produces the following output; 4 5 3 6 (12 Replies)
Discussion started by: mmab
12 Replies

8. Shell Programming and Scripting

Finding the length of the longest column

Hi, I am trying to figure out how to get the length of the longest column in the entire file (because the length varies from one row to the other) I was doing this at first to check how many fields I have for the first row: awk '{print NF; exit}' file Now, I can do this: awk '{ if... (4 Replies)
Discussion started by: MIA651
4 Replies

9. Shell Programming and Scripting

wc -L giving incorrect length of longest line

Running below line gives 3957 as length of longest line in file 20121119_SRMNotes_init.dat awk ' { if ( length > 3950 ) { x = length } }END{ print x }' 20121119_SRMNotes_init.dat While wc -L 20121119_SRMNotes_init.dat gives output as 4329. Why is there a difference between these two commands.... (2 Replies)
Discussion started by: Satish Mantha
2 Replies
readfile(1F)							   FMLI Commands						      readfile(1F)

NAME
readfile, longline - reads file, gets longest line SYNOPSIS
readfile filename longline [filename] DESCRIPTION
The readfile function reads filename and copies it to stdout. No translation of NEWLINE is done. It keeps track of the longest line it reads and if there is a subsequent call to longline, the length of that line, including the NEWLINE character, is returned. The longline function returns the length, including the NEWLINE character, of the longest line in filename. If filename is not specified, it uses the file named in the last call to readfile. EXAMPLES
Example 1: Typical use of readfile and longline Here is a typical use of readfile and longline in a text frame definition file: . . . text="`readfile myfile`" columns=`longline` . . . ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
cat(1), attributes(5) DIAGNOSTICS
If filename does not exist, readfile will return FALSE (that is, the expression will have an error return). longline returns 0 if a readfile has not previously been issued. NOTES
More than one descriptor can call readfile in the same frame definition file. In text frames, if one of those calls is made from the text descriptor, then a subsequent use of longline will always get the longest line of the file read by the readfile associated with the text descriptor, even if it was not the most recent use of readfile. SunOS 5.10 5 Jul 1990 readfile(1F)
All times are GMT -4. The time now is 04:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy