From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96076327921400.tru64-unix-managers.marc@archive.invalid> From: "Anil Khullar, Computer Center" Date: Mon, 22 Jan 1996 13:20:13 +0000 To: tru64-unix-managers Subject: SUMMARY: Tools to determine max record length, line size etc in a file X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96076327921400 Thanks to everyone for a quick reply, In no particular order to - John Hascall Peter Kaiser Steve Gibbons Ian Piumarta alan@nabeth.cxo.dec.com (Alan Rollow) Winfried Huber Larry Griffith 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