473,490 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How we get last created folder in one folder

3 New Member
How we pick last created file name of a folder
Apr 25 '07 #1
5 7370
michaelb
534 Recognized Expert Contributor
I assumed (from the title) that you don't need to look recursively into subdirectories.
If this is the case you can try this command
Expand|Select|Wrap|Line Numbers
  1. ~/public_html> ls -tAF | grep '/$' | head -1
  2. include/
  3. ~/public_html> 
  4.  
It is of course a bit ugly...
Apr 25 '07 #2
michaelb
534 Recognized Expert Contributor
I just realized that I did not get your question right - you are looking for the last updated file in the directory... In this case the code needs a tweak:

Expand|Select|Wrap|Line Numbers
  1. ~>  ls -tAF | grep -v '/$' | head -1
  2.  
Apr 26 '07 #3
ghostdog74
511 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. ls -tr |tail -1 |awk '{print $NF}'
  2.  
Apr 26 '07 #4
michaelb
534 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. ls -tr |tail -1 |awk '{print $NF}'
  2.  
Nice, but this code does not distinguish between files and folders; I think that rahulhere specifically wanted to get the latest folder (or file ?)
Apr 27 '07 #5
ValHolla
8 New Member
Expand|Select|Wrap|Line Numbers
  1. find . -type d -prune -exec ls -rt {} \; |tail -1
This code will give you the "LAST" directory listed in the current directory
depending on your OS you the -prune option may be -maxdepth 1 instead

Expand|Select|Wrap|Line Numbers
  1. find . -type d -maxdepth 1 -exec ls -rt {}\;|tail -1
Apr 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3705
by: george | last post by:
Guys and girls, I'll be quite honest. I don't have the faintest idea how to do this, while I can do other php without a problem. Once I know how to go about it I'll be okay. It's two things I...
0
840
by: BadMotherfucker | last post by:
Hello, I want to place some threads in an arraylist. (process is always the same) But no mather what I do, my tasks take allways the last thread, never one of the first created threads. I don't...
0
870
by: Kapil | last post by:
Hello Everybody, i have created a folder thorugh my ASP.NET application and now I want to assign the ASPNET user(admin) to modify permission on this folder. Is it possible that by using ...
0
1735
by: Vayse | last post by:
Hi I'm working on a program that stores information about the folder list on a server. I've listed the code I have below. Everything works fine, except I don't know how to get the name of the...
2
4804
by: MichiMichi | last post by:
My asp.net application has a directory which is filled up with over 17 files (email) a second. After a while this sums up into a huge amount of files. I usually count files with the GETFILES...
1
1521
by: Keith G Hicks | last post by:
Asp.net 2.0 - coding in VB I'm trying to get the UserID of the last created user so I can use the value in another table. I'm not finding anything otu there that works for what I'm trying to do....
2
1665
by: aravind7190 | last post by:
Hi all, I created a folder with a code to lock all the files. Today i drag that folder to desktop, when i see in that folder no files are there.One control panel is automatically created and when...
2
1702
by: Johnson | last post by:
I created an ASP.NET Web Application (not Web Site) Project in Visual Studio 2008. It automatically created a folder named App_Data. Can I get rid of that or does ASP.NET actually need it for some...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.