View lastest content in the file

Thread Tools Search this Thread
Operating Systems AIX View lastest content in the file
# 1  
Old 01-09-2008
View lastest content in the file

May i know how can i view the lastest content of the log file. Currently, i use the "more" command :
more logfile

However, it will give me the content last year first and i had to keep using the space bar to move down to the lastest content for current date. How can i view the lastest content of the first ?

# 2  
Old 01-09-2008
Check the man page for the TAIL command - may be what you are looking for. Tail -f sounds like it will do what you are requesting.
# 3  
Old 01-09-2008
The more utility on AIX can be steered the same way as vi: the following key combination will all work:

<SHIFT>-<g>    go to the end of the file, 
<j>            scroll down (forward) one line
<k>            scroll up (backwards) one line
<u>            scroll up (backwards) half a screen content
<d>            scroll down (forwards) half a screen content
<n><SHIFT>-<g> go to the <n>-th line ("1G" -> go to first line)

Use the tail utility, as has already been mentioned.

Alternatively use sed to display the last line or group of last lines, like this:

sed -n '$p' /path/to/file (will display the last line)

Alternatively use the sort utility to reverse order of lines in the file prior to displaying it:

sort -r /path/to/file | more

And finally there are perhaps a dozen of other possiblities to achieve the same which i just don't know of.

Hope this helps.


Last edited by bakunin; 01-09-2008 at 11:22 AM..
# 4  
Old 01-10-2008
Hi All,
Thanks for all the good option. I manage to get what i want from those command.

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

There are multiple filenames in the directory.How to return the the lastest files for each file name

there are mutiple file nams in the directory. How to return the the lastest files for each file name. ex. abc1234_050201 abc1234_050206 abc1234_050208 xyz34_050204 xyz34_050210 xyz34_050218 thanks (4 Replies)
Discussion started by: grand_sam
4 Replies

2. Shell Programming and Scripting

How to remove exisiting file content from a file and have to append new file content?

hi all, i had the below script x=`cat input.txt |wc -1` awk 'NR>1 && NR<'$x' ' input.txt > output.txt by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

3. Shell Programming and Scripting

Take only lastest file matching the pattern

Hi All , I have some fille names in a file which are sorted according to date. for example file1_123.log 23 Jul 0Kb file2_123.log 22 Jul 2Kb file3_123.log 20 Jul 0Kb file1_456.log 24 Jul 2Kb file2_678.log 22 Jul 0Kb file2_678.log 21 Jul 2Kb here 123 is a... (2 Replies)
Discussion started by: LoneRanger
2 Replies

4. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

5. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

6. Shell Programming and Scripting

Remove all folders within another folder except the lastest 1, 2 or 3.

I am using this command to remove all files and folders older than 24 hours; find /databackup/dbs/* -maxdepth 0 -type d -mtime +0 -exec rm -rf {} \; However, if/when backups to this folder fail and are not updated, it will completely destroy any backups we have in that folder. What can I add... (14 Replies)
Discussion started by: damang111
14 Replies

7. AIX

Alternative URL to check for the lastest TLs

Hi all, I'm sorry to post this question, but I searched and searched and search but I did not find an alternative url for this one: (53) I used this site to check for the latest TLs. Thanks in advanced :) tex (3 Replies)
Discussion started by: tex09
3 Replies

8. UNIX for Advanced & Expert Users

Can't view directory content - SUNOS

Hi, The app I support has a directory used for debugg files. It has just come to light there are no files in there. Or is there :confused: Changing into the directory and completing an ls -lta you get no files. This is truly not right for the application. If I go up one directory the... (2 Replies)
Discussion started by: nhatch
2 Replies
Login or Register to Ask a Question