The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script to find latest executable in particular directory and start that particular ex kvineeth Shell Programming and Scripting 6 09-24-2007 04:19 AM
Find all files created by a specified user in a directory and its subdirectories abhilashnair UNIX for Dummies Questions & Answers 5 06-12-2007 11:37 PM
want to cat the latest log file created vkandati UNIX for Dummies Questions & Answers 1 03-08-2005 02:13 PM
ksh: How to get latest file from a list of files in a directory Jayathirtha Shell Programming and Scripting 1 06-24-2003 07:23 AM
new directory - how to force files created in it to inherit grp,own and permissions avisb UNIX for Dummies Questions & Answers 2 04-26-2002 01:47 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-12-2008
Registered User
 

Join Date: May 2008
Posts: 2
Get the latest directory created

hi,
I need to get the latest directory created for example wheni run
ls -altr *xyz_Integration*
I have plenty of directories created like

my_build_77_xx_Integration_050908_150714:
total 177898
-rw-rw--- 1 xyzmgr cchyg 7687338 May 9 19:29 myapp.ear

my_build_77_xx_Integration_050908_163337:
total 177898
-rw-rw--- 1 xyzmgr cchyg 7687338 May 9 19:29 myapp.ear

my_build_77_xx_Integration_050908_165636:
total 177898
-rw-rw--- 1 xyzmgr cchyg 7687338 May 9 19:29 myapp.ear

my_build_77_xx_Integration_050908_183534:
total 177898
-rw-rw--- 1 xyzmgr cchyg 7687338 May 9 19:29 myapp.ear

my_build_77_xx_Integration_050908_191844:
total 177898
-rw-rw--- 1 xyzmgr cchyg 7687338 May 9 19:29 myapp.ear


I need to print only the name of the latest directory created like

my_build_77_xx_Integration_050908_191844

Can anybody help me in getting this..
I am new to scripting.

Thanks
Vikram
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-12-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,494
Code:
ls -lrt *xyz_Integration* | tail -1
Reply With Quote
  #3 (permalink)  
Old 05-12-2008
Registered User
 

Join Date: May 2008
Posts: 2
Hi
Thx for the response..
I am having multiple files under the same directory
my_build_59_xx_Integration_050908_191844:
total 177860
-rw-rw-r-- 1 xyzmgr ccbbld 39238299 May 9 19:29 app.ear
-rw-rw-r-- 1 xyzmgr ccbbld 51716251 May 9 19:29 my.ear
drwxrwxr-x 2 fxyzmgr ccbbld 512 May 9 19:29 src
drwxrwxr-x 3 xyzmgr ccbbld 512 May 9 19:29 cfg
-rw-rw-r-- 1 xyzmgr ccbbld 16468 May 9 19:29 my.jar
drwxrwxr-x 4 xyzmgr ccbbld 512 May 9 19:29 data
drwxrwxr-x 3 xyzmgr ccbbld 512 May 9 19:29 cfg02
drwxrwxr-x 6 xyzmgr ccbbld 512 May 9 19:29 .
drwxrwxr-x 42 xyzmgr ccbbld 3584 May 12 12:03 ..

By running that command I can only get
drwxrwxr-x 3 xyzmgr ccbbld 512 May 9 19:29 cfg02
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0