Read directories sequential based on timestamp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read directories sequential based on timestamp
# 1  
Old 05-22-2012
Read directories sequential based on timestamp

Hi,
I have a directory structure like below
Directoryname create time
d1 12:00
d2 12:05
d3 12:08

I want to read the directories based on timestamp.That is oldest directory must be read first and kick off certain process.

Kindly let me know how can read these directories.

Thanks,
Chetan
# 2  
Old 05-22-2012
Use ls -td to list the directories sorted by timestamp instead of name. Use the -r switch to reverse the sorting order (in case you need that).

I hope this helps.

bakunin
# 3  
Old 05-22-2012
Quote:
Originally Posted by bakunin
Use ls -td to list the directories sorted by timestamp instead of name. Use the -r switch to reverse the sorting order (in case you need that).

I hope this helps.

bakunin
Thanks.
Apologies I did not give the complete information .

I require it to be in a for loop ,so that once the oldest directory is read the subsequent oldest directory is picked. The process after the directory name is picked is independant so it has to be a continuos process.

Thanks,
Chetan.C
# 4  
Old 05-22-2012
Try
Code:
for i in $(ls -1Frt|grep '/$'|tr -d '/$')
do
#### processing with directory i ####
done

This User Gave Thanks to elixir_sinari For This Post:
# 5  
Old 05-22-2012
Quote:
Originally Posted by chetan.c
once the oldest directory is read the subsequent oldest directory is picked.
What does it mean? Do you mean sub directories?
Also from continuous processing do you mean parallel?
# 6  
Old 05-22-2012
Quote:
Originally Posted by elixir_sinari
Try
Code:
for i in $(ls -1Frt|grep '/$'|tr -d '/$')
do
#### processing with directory i ####
done


Thanks!! its working Completing the script now...thanks again!Smilie

---------- Post updated at 07:18 AM ---------- Previous update was at 07:17 AM ----------

Quote:
Originally Posted by anchal_khare
What does it mean? Do you mean sub directories?
Also from continuous processing do you mean parallel?
Hi Anchal,

Actually for each directories i have ETL jobs that need to be triggered.
That is why i was looking for such option.


Thanks,
Chetan.C

---------- Post updated at 07:22 AM ---------- Previous update was at 07:18 AM ----------

Hi elixir_sinari,

Can you explain me what it is doing .Im doing a man for
Code:
-F

option of ls it says append indicator.So can i know what it means?


Thanks,
Chetan.C
# 7  
Old 05-22-2012
Quote:
Originally Posted by chetan.c
Hi elixir_sinari,

Can you explain me what it is doing .Im doing a man for
Code:
-F

option of ls it says append indicator.So can i know what it means?


Thanks,
Chetan.C
Here's the man page section for the option:

Code:
 -F
      Puts a / (slash) after each file name if the file is a directory, an * (asterisk) if the file can be executed,
      an = (equal sign) if the file is a socket, a | (pipe) sign if the file is a FIFO, and an @ for a symbolic link.
      Symbolic links that are named as operands are not followed unless you have specified the -H or -L flag.

This is on AIX 5.3
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Giving read write permission to user for specific directories and sub directories.

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies

2. Shell Programming and Scripting

awk to adjust coordinates in field based on sequential numbers in another field

I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines. If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

4. UNIX for Dummies Questions & Answers

[Solved] awk solution to add sequential numbers based on a word

Hi experts, I've been struggling to format a large genetic dataset. It's complicated to explain so I'll simply post example input/output $cat input.txt ID GENE pos start end blah1 coolgene 1 3 5 blah2 coolgene 1 4 6 blah3 coolgene 1 4 ... (4 Replies)
Discussion started by: torchij
4 Replies

5. Shell Programming and Scripting

Need help: Script to report timestamp of directories in a specific path from multiple Linux server

Need help Please help on how to write a script which can echo timestamp, size of subdirectories in a specific path from multiple Linux servers to a text file. I can ssh with a common user to all the servers from a build box. Basic idea what I had was: ssh <commonuser>@<each box> cd... (1 Reply)
Discussion started by: sudhichadaga
1 Replies

6. Shell Programming and Scripting

Rename files in sub directories with sequential numbers

I can rename a file with sequential numbers from 1 to N with this script: num=1 for file in *.dat;do mv "$file" "$(printf "%u" $num).txt" let num=num+1 done The script begins with renaming a some.dat file to 1.dat.txt and goes on sequentially renaming other DAT files to... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. Programming

Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX

Writing a Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX I have over the years come across the same issue a couple of times, and it normally is that the read speed on SAN is absolutely atrocious when doing non-sequential I/O to the disks. Problem being of... (7 Replies)
Discussion started by: vrghost
7 Replies

8. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

9. Programming

Reading special characters while converting sequential file to line sequential

We have to convert a sequential file to a 80 char line sequential file (HP UX platform).The sequential file contains special characters. which after conversion of the file to line sequential are getting coverted into "new line" or "tab" and file is getting distorted. Is there any way to read these... (2 Replies)
Discussion started by: Rajeshsu
2 Replies
Login or Register to Ask a Question