Determining file length


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Determining file length
# 1  
Old 07-07-2006
Determining file length

How can I determine what UNIX thinks the record size of any given file is??
# 2  
Old 07-07-2006
Code:
#/bin/ksh
# longest record length in the file
# works only for carriage control files
awk '
    BEGIN{len = 0}
    { z=length($0)
      if(z>len)
      {
         len=z
      }
    }
    END {print len}
  '  fileaname

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Determining length of string

I have this script which is very easy: file=`echo 01114` echo $file 01114 then I ran this if ; then echo "yes";fi it returned yes even though there are only 5 digits there So then I tried file=`echo abcd` echo $file abcd if ]; then echo "yes";fi if ]; then echo "yes";fi It... (2 Replies)
Discussion started by: newbie2010
2 Replies

2. Shell Programming and Scripting

Efficient method of determining if a string is in a file.

Hi, I was hoping someone could suggest an alternative to code I currently have as mine takes up far too much processor time and it to slow. The situation: I have a programme that runs on some files just before they are zipped up and archived, the program appends a one line summary of the... (4 Replies)
Discussion started by: RECrerar
4 Replies

3. Shell Programming and Scripting

Flat file-make field length equal to header length

Hello Everyone, I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table. Input Data- ------ ------------------------ ---- ----------------- WFI001 Xxxxxx Control Work Item A Number of Records ------ ------------------------... (5 Replies)
Discussion started by: sonali.s.more
5 Replies

4. UNIX for Dummies Questions & Answers

Determining file size for a list of files with paths

Hello, I have a flat file with a list of files with the path to the file and I am attempting to calculate the filesize for each one; however xargs isn't playing nicely and I am sure there is probably a better way of doing this. What I envisioned is this: cat filename|xargs -i ls -l {} |awk... (4 Replies)
Discussion started by: joe8mofo
4 Replies

5. Programming

Determining file access perms for current process

Stupid question, but is there an ANSI C stdlib function that will do this for me? I want to pass the function a path and determine if the current process can read/write/execute on the path. I suppose I can whip something up using fstat and then determining the current process's user/group IDs and... (6 Replies)
Discussion started by: DreamWarrior
6 Replies

6. Shell Programming and Scripting

Determining position in a tab delimited file

hi, I want to determine the position of specific values over a cutoff. So I have a string of values that are mainly negative in number and I want to print the rare few that are positive. Specifically I want to know the position of the value along the string. The position is based from right to... (11 Replies)
Discussion started by: phil_heath
11 Replies

7. UNIX for Dummies Questions & Answers

Convert a tab delimited/variable length file to fixed length file

Hi, all. I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file: 10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783 19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657 And this is the expected... (2 Replies)
Discussion started by: Everton_Silveir
2 Replies

8. 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

9. Shell Programming and Scripting

Problem determining file

I got the following code, it partially works. Can someone tell me why it partially doenst work? #!/bin/sh file=$1 if then echo "File is a directory" else echo "File is not a directory!" fi heres the output: philip@philip-laptop:~/Desktop$ sh exFive.sh test.java File is... (4 Replies)
Discussion started by: philmetz
4 Replies

10. UNIX for Dummies Questions & Answers

Determining type of file

Hello, I'm attempting to modify a script so it can be executed via a batch scheduler. Part of the script calls a program called direct (which I believe may have something to do with Connect Direct). I have tried cat and vi on the file; cat returns absolute gibberish, vi states the file is... (2 Replies)
Discussion started by: JWilliams
2 Replies
Login or Register to Ask a Question