Computing.Net > Forums > Unix > display files contents

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

display files contents

Reply to Message Icon

Name: bhben
Date: October 1, 2004 at 02:19:52 Pacific
OS: Windows XP
CPU/Ram: P4, 512MB
Comment:

Hi all,

I am trying to display the contents of a file, the file that i want to display the contents of is a different file every day.

When i use the ls -lrt command the file that i wish to display using pg, is always the last one so if i use tail -1 i can get this file with all its details.

I then want to pg this file to display its contents from within a script.

Note if i do an ls rather than ls -lrt the file i want is no longer the last one and thus the tail -1 command won't find the correct file.

What i need to do is the ls -lrt | tail -1 to find the correct file, then strim this so that i am left with just the filename and then pg this file, all from within a script. I can't figure this bit out!

The .trc files that i am searching for are created everyday so i am always looking for the most recent one.

Hope someone can help, Thanks.




Sponsored Link
Ads by Google

Response Number 1
Name: Jc
Date: October 1, 2004 at 05:10:20 Pacific
Reply:

ls -tr |tail -1


Jc


0

Response Number 2
Name: bhben
Date: October 1, 2004 at 06:36:19 Pacific
Reply:

Thanks, although now i have the name of the correct file i still need to display its contents so that when i run my script the contents of the files will be displayed.


0

Response Number 3
Name: Jim Boothe
Date: October 1, 2004 at 09:32:43 Pacific
Reply:

Don gave you the syntax in the prior thread:

pg `ls -tr | tail -1`


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: display files contents

Cannot display `pwd` content under www.computing.net/answers/unix/cannot-display-pwd-content-under-/6163.html

how to validate a file content? www.computing.net/answers/unix/how-to-validate-a-file-content/5567.html

pg a file within a script www.computing.net/answers/unix/pg-a-file-within-a-script/6503.html