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 8515529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:10:18+00:00 2026-06-11T05:10:18+00:00

I have a directory with files whose names are common with a suffix of

  • 0

I have a directory with files whose names are common with a suffix of increasing date.

An example is:

REUTERS.FH_lbm_dump.20120905 

representing the 5th of September.

These files are supposed to be created in the first few minutes of the next day, e.g. the above file should’ve been created at 00:01 on the 6th of September.

However, due to some bug with how the filenames are generated, an application has been saving them incorrectly. So files created at 00:16 on the 5th of September have the suffix 20120905, i.e. the filename is 1 day too late.

Output from ls -h showing the wrong naming:

2012-09-05 00:16 FH_lbm_dump.20120905

So logic to detect this would look at the file name, extract the date, and if its equal to the file timestamp it would be positive.

How can we do this in Bash / Perl / Python?

  • 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. Editorial Team
    Editorial Team
    2026-06-11T05:10:20+00:00Added an answer on June 11, 2026 at 5:10 am

    I will not solve your entire problem, but I’ll give you a place to start. The rest is really up to you.

    #!/bin/bash
    
    # loop through all filenames in current dir
    for filename in *; do
    
        # How to extract the date from the file name
        date_from_file=${filename:(-8)}
    
        # How to get the file's modification date in the same format
        date_modified=$(stat -c %y "$filename" | cut -d ' ' -f1 | sed 's/-//g')
    
        # test for inequality
        if [ $date_from_file -ne $date_modified ]; then
    
            ... # do your thing
    
        fi
    
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a directory of XML files... for example: result.xml result2.xml result3.xml resultNth.xml (because
I have a find command that I run to find files whose names contain
I have to transfer files whose names consists of two variables X, Y and
I have directory A with files matching directory B. Directory A may have other
I have a directory of files on a web server. I want the files
I have a directory with files that look like this: 001_something.php 002_something_else.php 004_xyz.php 005_do_good_to_others.php
I have a directory with timestamped files in the format: processAlpha20120618.txt processAlpha20120619.txt processAlpha20120620.txt processBeta20120618.txt
I have a directory of SRT files, formated: 8 00:00:45,879 --> 00:00:50,680 - Oh!
I have a directory of ZIP files (created on a Windows machine). I can
I have directory with > 1000 .html files, and would like to check all

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.