473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How we get last created folder in one folder

How we pick last created file name of a folder
Apr 25 '07 #1
5 7366
michaelb
534 Expert 512MB
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 Expert 512MB
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 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. ls -tr |tail -1 |awk '{print $NF}'
  2.  
Apr 26 '07 #4
michaelb
534 Expert 512MB
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
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
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
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
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
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
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
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
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
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.