The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error- ld.so.1: expr: fatal: libgmp.so.3: open failed:No such file or directory Hari_Ganesh SUN Solaris 2 07-16-2009 06:52 AM
libRmath.so: cannot open shared object file: No such file or directory cdbug High Level Programming 6 02-28-2009 11:43 PM
perl find directory only if modified in last hour frustrated1 Shell Programming and Scripting 0 10-12-2007 05:50 PM
how to retrieve original contents of a modified file (modified using vi) novice100 UNIX for Dummies Questions & Answers 3 05-31-2007 09:50 PM
How to zip a modified file 15 days before but not scanning my sub directory files skrish70 Shell Programming and Scripting 1 10-10-2005 04:41 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 09-26-2009
apsprabhu apsprabhu is offline
Registered User
  
 

Join Date: Feb 2008
Location: India
Posts: 45
how to open a last modified file in a directory

how to directly open a last modified file in a directory? Please help
  #2 (permalink)  
Old 09-26-2009
malcomex999 malcomex999 is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 151
not a good way but i guess it does what you want...
Code:
 
ls -lrt | awk '/^-/{file=$9}END{print "cat " file}' | sh
  #3 (permalink)  
Old 09-26-2009
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,777
Code:
while read record
do
   echo "$record"
done < $(ls -rt /path/to/file| tail -1)
  #4 (permalink)  
Old 09-26-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,910
To open or display?
If you want to edit the most recently modified file with vi from zsh for example:

Code:
vi -- *(D.om[1])
  #5 (permalink)  
Old 10-01-2009
sunilk1303's Avatar
sunilk1303 sunilk1303 is offline
Registered User
  
 

Join Date: Aug 2009
Location: Los Angeles
Posts: 3
cat `ls -ltr | awk '{file=$9}END{print file}'`
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0