Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 94893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:34:22+00:00 2026-05-10T23:34:22+00:00

I’m trying to do what I think is a simple thing under Linux. I

  • 0

I’m trying to do what I think is a simple thing under Linux. I have a bash script which runs various test programs, and I want to determine which files in the current directory were created by the test programs. So I am doing something like this:

 touch timestamp-file run the test find -newer timestamp-file -type f > list-of-files rm -f timestamp-file 

Turns out the granularity of find -newer is poor, so what typically happens is that some files which were generated by the test program show up as OLDER than the timestamp file. So then I tried this:

 ls -tr1 | sed '1,/timestamp-file/d' 

to generate the same list. This usually works, but not always. I still end up with the situation where files which were generated by the test show up as older than the timestamp file.

Thanks!

P.S. I can accomplish this another way by taking two snapshots of the directory, one before the test program runs, and then one after, and comparing them. Any files in the second list which are not in the first must have been created by the test program (I’m not concerned with background jobs or other users writing to the dir). But this method is not what I want because if an output file wasn’t removed prior to running the test (they’re supposed to be, but in some cases they may not be), this method will say it was not created by the test program because it was in the dir before the test program was run.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:34:23+00:00Added an answer on May 10, 2026 at 11:34 pm

    Take the filenames of all the files before the run, but include their timestamps:

    find -printf '%p %T@\n' | sort > file1 

    If you haven’t got that find option available, you can use stat for that job too:

    find -print0 | xargs -0 stat -c '%n %Y' | sort > file1 

    And after the run to file2. Then use

    comm -1 -3 file1 file2 

    And it will show you the lines unique to file2, which must be new files if i’m not mistaken. If they existed before, their modification time will have changed, which is taken care by the %T@ thingy (printing out the number of seconds since 1970):

     [js@HOST2 cpp]$ find -printf '%p %T@\n' | sort > file1 [js@HOST2 cpp]$ echo foo>bar [js@HOST2 cpp]$ echo foo>baz [js@HOST2 cpp]$ find -printf '%p %T@\n' | sort > file2 [js@HOST2 cpp]$ comm -1 -3 file1 file2 . 1230947309.0000000000 ./bar 1230947308.0000000000 ./baz 1230947309.0000000000 ./file2 1230947315.0000000000 [js@HOST2 cpp]$ find -printf '%p %T@\n' | sort > file1 [js@HOST2 cpp]$ echo lol>bar [js@HOST2 cpp]$ find -printf '%p %T@\n' | sort > file2 [js@HOST2 cpp]$ comm -1 -3 file1 file2 ./bar 1230947359.0000000000 ./file2 1230947362.0000000000 [js@HOST2 cpp]$` 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.