By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,693 Members | 1,972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,693 IT Pros & Developers. It's quick & easy.

how to find a last updated directory?

P: 89
Suppose I have a set of directories as lane1, lane2, lane3, file1, file2..under /home/userrig/test in a linux server. And the last updated directory is lane3.

lane1, lane2 and lane3 are directories and file1 and file2.. are under files under /home/userrig/test.

I am only interested in directory that starts with
Expand|Select|Wrap|Line Numbers
  1. lane

How do I collect this information? Infact after cheking for the last updated directory, I have to change to that directory and execute a command in
Expand|Select|Wrap|Line Numbers
  1. system("execute");
method.

Is there any function to sort the directory according to time like "ls - lt" as in unix command? Please let me know how to proceed?

Thanks and Regards
Jul 16 '08 #1
Share this Question
Share on Google+
3 Replies


P: 89
Any expert advice or suggestions needed please.
Jul 17 '08 #2

P: 2
Suppose I have a set of directories as lane1, lane2, lane3, file1, file2..under /home/userrig/test in a linux server. And the last updated directory is lane3.

lane1, lane2 and lane3 are directories and file1 and file2.. are under files under /home/userrig/test.

I am only interested in directory that starts with
Expand|Select|Wrap|Line Numbers
  1. lane

How do I collect this information? Infact after cheking for the last updated directory, I have to change to that directory and execute a command in
Expand|Select|Wrap|Line Numbers
  1. system("execute");
method.

Is there any function to sort the directory according to time like "ls - lt" as in unix command? Please let me know how to proceed?

Thanks and Regards

I replied to ur last post also, here is the code that gets the latest directory whose name starts with lane.

Expand|Select|Wrap|Line Numbers
  1. my $latest_dir = (grep { chomp; /^lane/i } `ls -t`)[0];
regs,
Jul 17 '08 #3

P: 89
Thank you so much. As I overlooked my previous message, I couldn't respond. Sorry for the confusion caused.
Jul 17 '08 #4

Post your reply

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