Get the latest directory created


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get the latest directory created
# 1  
Old 05-12-2008
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
# 2  
Old 05-12-2008
Code:
ls -lrt *xyz_Integration* | tail -1

# 3  
Old 05-12-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

2. Shell Programming and Scripting

Traverse Latest directory First

I wish to traverse the latest to the oldest directory based on its timestamp. ls -ltr drwxr-x--- 3 admin bel 1024 Jan 22 02:29 sys drwxr-x--- 2 admin bel 2048 Jan 22 02:30 admin drwxr-x--- 10 admin bel 24576 Jan 23 21:31 bin For the above i need to cd first to... (2 Replies)
Discussion started by: mohtashims
2 Replies

3. Shell Programming and Scripting

Listing latest modified or created files recursively

Hi, I want to display latest files (created or modified) recursively in a path. I tried in different ways, but didn't get any desired output: find $path -type f -exec ls -lt {} \; | sort -n -r find $path -type f -printf %p";" | xargs -d ";" ls -t Second one is giving the error:... (21 Replies)
Discussion started by: karumudi7
21 Replies

4. UNIX for Dummies Questions & Answers

User's home directory not being created

I am trying to create Oracle user. I will install oracle after that. But my problem is /home/oracle directory is not being created. bash-3.2# useradd -g oinstall -G dba,oper -d /home/oracle -m oracle cp: /home/oracle: Operation not applicable chown: /home/oracle: No such file or directory ... (3 Replies)
Discussion started by: hubatuwang
3 Replies

5. AIX

How to find the date on which a particular directory is created?

how to find the date on which a particular directory is created? Thanks. (4 Replies)
Discussion started by: samsungsamsung
4 Replies

6. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

7. UNIX for Dummies Questions & Answers

pick the very latest directory

Hi, I have some list of directories in the form datemonthyear e.g. 02082009, 03082009 and 04082009 etc. I need to pick the latest directory from the current working directory. Outcome: 05082009 This is the output am expecting. Thanks (6 Replies)
Discussion started by: venkatesht
6 Replies

8. UNIX for Advanced & Expert Users

.SSH directory not created

I have created a new user account on my openssh system.But the .ssh directory was not created under my home dir home/A00d56/. Could any one please suggest me whether the .ssh directory will be created automatically when we add the new user or we need to manually create that after? The use of... (3 Replies)
Discussion started by: srrao.ch
3 Replies

9. UNIX for Dummies Questions & Answers

.ssh directory not created

I have created a new user account on my openssh system.But the .ssh directory was not created under my home dir home/A00d56/. Could any one please suggest me whether the .ssh directory will be created automatically when we add the new user or we need to create that after? The use of this new... (3 Replies)
Discussion started by: srrao.ch
3 Replies

10. UNIX for Dummies Questions & Answers

want to cat the latest log file created

everytime a new logfile get created at certain interval of time and i want a simple shell script program which cat the lastest log file when manually excuted (1 Reply)
Discussion started by: vkandati
1 Replies
Login or Register to Ask a Question