Find the answer to your Linux question:
Results 1 to 2 of 2
hello friends, actually i want to find oldest file in my folder whose path is given as command line argument. and after finding that file i want to delete that. ...
  1. #1
    Just Joined!
    Join Date
    May 2007
    Posts
    2

    how to find oldest file in folder n delete that

    hello friends,
    actually i want to find oldest file in my folder whose path is given as command line argument. and after finding that file i want to delete that.
    and there is also possibality that there may be more folders inside folder.
    my paltform is linux -2.6.16

    thanks

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    1. Define "the oldest file"? I mean to say, set some date/time to identify the oldest files.

    2. If you want to do using C, use scandir API to fetch all the files in the directory, use fstat API to read timestamps, compare the timestamp, then delete it.
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...