read the last line in file 
Author Message
 read the last line in file

hi, one quick question:

how can jump and read the last line from file with awk?

i don't want to get a big file in array, are there some other ways?

regards,



Mon, 01 Aug 2005 05:18:25 GMT  
 read the last line in file

Quote:

>hi, one quick question:

>how can jump and read the last line from file with awk?

>i don't want to get a big file in array, are there some other ways?

>regards,

use tail on the file instead

or not best: use tail on the file within awk using the system command

Chuck Demas

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Mon, 01 Aug 2005 03:31:30 GMT  
 read the last line in file

Quote:
> hi, one quick question:

> how can jump and read the last line from file with awk?

> i don't want to get a big file in array, are there some other ways?

awk 'END { print $0 }' file


Mon, 01 Aug 2005 03:35:45 GMT  
 read the last line in file

X hi, one quick question:
X
X how can jump and read the last line from file with awk?
X
X i don't want to get a big file in array, are there some other ways?
X
X regards,

If this is a UNIX system, then use the 'tail' utility.  If the file is
large, then 'tail' will be much more efficient since it will start at
the end of the file looking for the last line.  Awk would have to read
every line in the file to find the last one.  For short files,
expecially if you needed to then process the data in the last file, then
letting awk read the entire file and process it would be faster than
invoking 2 programs.  But once the file gets to be large, using tail to
get the line and piping it to awk would be faster:

        tail -1 filename | awk '{do something with the line here}'

                                        Bob Harris



Mon, 01 Aug 2005 09:51:25 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to read the x last lines of a text file

2. How to read the last line of http:// file

3. File: How to read the last line?

4. how to read text files line by line?

5. reading file line by line

6. new question in how can i read data from file line by line

7. line-by-line file read

8. Read a text file line by line

9. join last 2 lines of a file

10. deleting newline from last line in file

11. print last line of input file

12. how to specify last line of file ?

 

 
Powered by phpBB® Forum Software