to read oldest 100 files from a directory till all end
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > to read oldest 100 files from a directory till all end




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    to read oldest 100 files from a directory till all end  
shruti.dabhade@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-22-06 06:18 PM

hii
my doubt is this-
from a directory i wud like to read the files stored there.
but i want it to happen like this-
read only 100 files at a time.go on reading 100-100 till all files have
been read.
also it shud always read the oldest files first.
i.e files shud be read in the order tht they had come to the folder.

can somebody plz help me wid this.
its really urgent.

thanx in advance

-shruti.






[ Post a follow-up to this message ]



    Re: to read oldest 100 files from a directory till all end  
Gordon Burditt


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-23-06 12:20 AM

>from a directory i wud like to read the files stored there.
>but i want it to happen like this-
>read only 100 files at a time.go on reading 100-100 till all files have
>been read.
>also it shud always read the oldest files first.
>i.e files shud be read in the order tht they had come to the folder.

Make a list of files in the directory, using opendir() and readdir().
The results will come in no particular order.

There is no guaranteed way you can tell "when a file came to the folder".
You can get close with st_mtime or st_ctime from stat() on each file.

Sort the files by time.  Perhaps this is an in-memory sort with qsort().

I don't know what you mean by "read 100 files at a time".  Open 100
files, read a byte from each, repeat reading the next byte from
each file until end-of-file?

Gordon L. Burditt





[ Post a follow-up to this message ]



    Re: to read oldest 100 files from a directory till all end  
Bill Marcum


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-24-06 12:20 AM

On 22 Jul 2006 10:25:44 -0700, shruti.dabhade@gmail.com
<shruti.dabhade@gmail.com> wrote:
> hii
> my doubt is this-
> from a directory i wud like to read the files stored there.
> but i want it to happen like this-
> read only 100 files at a time.go on reading 100-100 till all files have
> been read.
> also it shud always read the oldest files first.

popen("ls -tr", "r")


--
My apologies if I sound angry.  I feel like I'm talking to a void.
-- Avery Pennarun





[ Post a follow-up to this message ]



    Re: to read oldest 100 files from a directory till all end  
Swarup Baran


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-25-06 12:48 PM


Bill Marcum wrote:
> On 22 Jul 2006 10:25:44 -0700, shruti.dabhade@gmail.com
>   <shruti.dabhade@gmail.com> wrote: 
>
> popen("ls -tr", "r")
>
>
> --
> My apologies if I sound angry.  I feel like I'm talking to a void.
> 	-- Avery Pennarun


Here is how you can list n oldest files

ls -lrt <directory>/<file extensions> | grep -v total | awk -F " "
'{print $9}' | head -100

this will list 100 oldest files of particular extension in a given
directory

Regards,
Swarup

You will if you can,
You won't if you can't






[ Post a follow-up to this message ]



    Re: to read oldest 100 files from a directory till all end  
Chris McDonald


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-25-06 12:48 PM

"Swarup Baran" <swarup.baran@gmail.com> writes:

>Here is how you can list n oldest files

>ls -lrt <directory>/<file extensions> | grep -v total | awk -F " "
>'{print $9}' | head -100

>this will list 100 oldest files of particular extension in a given
>directory

Or something like:

ls -F1t | grep -v '[*@/=]$' | head -100

---
Chris,





[ Post a follow-up to this message ]



    Re: to read oldest 100 files from a directory till all end  
jmcgill


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-11-06 06:31 AM

Swarup Baran wrote:

> Here is how you can list n oldest files
>
> ls -lrt <directory>/<file extensions> | grep -v total | awk -F " "
> '{print $9}' | head -100
>
> this will list 100 oldest files of particular extension in a given
> directory
>

ouch.  Getting the *next*, an n*100th, files will be a neat trick from here.





[ Post a follow-up to this message ]



    Re: to read oldest 100 files from a directory till all end  
Eric Sosman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-11-06 06:40 PM



jmcgill wrote On 08/10/06 21:18,:[vbcol=seagreen]
> Swarup Baran wrote:
>
> 
>
>
> ouch.  Getting the *next*, an n*100th, files will be a neat trick from here.[/vbco
l]

.. | head -200 | tail -100

--
Eric.Sosman@sun.com






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:55 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register