SUMMARY: Tools to determine max record length, line size etc in a file

From: Anil Khullar, Computer Center <Anil.Khullar_at_mailhub.gc.cuny.edu>
Date: Mon, 22 Jan 1996 09:20:13 -0400 (EDT)

Thanks to everyone for a quick reply, In no particular order to -
 John Hascall <john_at_iastate.edu>
 Peter Kaiser <kaiser_at_heron.enet.dec.com>
 Steve Gibbons <steve_at_aztech.net>
 Ian Piumarta <piumarta_at_prof.inria.fr>
 alan_at_nabeth.cxo.dec.com (Alan Rollow)
 Winfried Huber <win_at_tukan.ffb.eunet.de>
 Larry Griffith <larry_at_liz.wsc.mass.edu>

SUMMARY: In unix record length and other charactersitics do not exist in
         the sense it does on VMS or other OSs.
         Internal chararistics of a file is left to the application
         that generates it or is left to the individual program.
         Non unix type files is rather more difficult.

         For most unix files that use standard new line, most of you'll
        suggested the use of awk.

For now, all non-unix non-ascii IBM type files that arrive on tape, I
plan to keep using our old tapetools (VMS), however for unix datafile intended
for shipping out to various sites, I'll use awk.

Thanks once again. The various awk solutions are attached below and my
original is in the bottom.

anil
;-------------------------------------
I think this is what you are looking for:

   awk 'length($0) > MAX {MAX=length($0)} END {print MAX}'

for example:

   awk 'length($0) > MAX {MAX=length($0)} END {print MAX}' < /etc/motd
--------------------------------------------------
        awk '{print length}' | sort -n | tail -1
---------------------------------------------------
        awk '{ print length($0) }' file | sort -rn | head -1
-----------------------------------------------------
expand YourFileName | awk '{ if (x < length()) x = length() }\
END { print "maximum line length is " x }'

To print lines longer than 80 characters use
expand file | awk 'length()>80'
--------------------------------------------------------------
MY ORIGINAL QUERY.

>
> hi,
> I've been looking for tools which give me information
> similar to VMS's file utilities. I'm specifically interested
> in determining information such as largest record length in a
> file etc. The closest command I note is wc, which is not what I need.
> The files I have received are mostly data files brought over from
> various non-unix environments.
>
> Under VMS a combination of ANALY/RMS, and a Public domain
> FILE util gave sufficient information about the file. I do understand
> that RMS constructs do not exist in unix, then how do folks figure out
> max line lengths, or max record size etc so that users using these files
> (mostly large datasets) read it into SAS, SPSS, BMDP or whatever for their
> analysis ?
>
> Thanks in advance, and if I've been unable of clarify what I'm looking
> for then I apologize for it.
>
> Anil Khullar
Received on Mon Jan 22 1996 - 16:16:33 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:46 NZDT