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

The Archive Base Latest Questions

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

I am trying to delete files from the Unix directory which starts with EXPORT_v1x0

  • 0

I am trying to delete files from the Unix directory which starts with EXPORT_v1x0 and whose date is less than 2013-01-25 (Jan 25th 2013). I can delete the files one by one but it will take few days for me to delete all the files. Is there any better way to delete the files with the specific pattern?

Below are the sample files when I do ls

bash-3.00$ ls /data/bds/real
EXPORT_v1x0_20120811.dat.gz 
EXPORT_v1x0_20120811.dat.gz   

If you see the above files. Each file has a date in that. Suppose we take this file into the consideration-

EXPORT_v1x0_20120811.dat.gz

It’s date is 20120811 So I need to delete all the files which starts with EXPORT_v1x0 and whose date is less than 20130125. So If I am supposed to delete all the files having date less than 20130125 then all the files above I mentioned will get deleted as there dates are less than 20130125.

NOTE:- All the files are having same pattern exactly as I mentioned above. Only date and other numbers followed by that are different.

So I just need to delete all the files which starts with EXPORT_v1x0 and whose date is less than 20130125.

I am running SunOS. I am still in the process of learning Unix better. So not sure of any high ends commands and scripts.

  • 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-18T07:21:12+00:00Added an answer on June 18, 2026 at 7:21 am

    A first naive approach to the problem, tweek it to your needs:

    find . | awk -F'_' '$3<20130125' | xargs rm
    

    To prevent find from doing a recursive search and just stay in current folder:

    find . \( ! -name . -prune \) -type f | ...
    

    2nd update:

    Add the name parameter to only list files that contains the string “EXPORT_v1x0”

    find . \( ! -name . -prune \) -type f -name "EXPORT_v1x0*" | ...
    

    Simpler way to make find non-recursive is to use the maxdepth flag

    find . -maxdepth 1 -type f -name "EXPORT_v1x0*" | ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a cron job which will automatically delete .jpg files from
I'm trying to delete old SVN files from directory tree. shutil.rmtree and os.unlink raise
Im trying to Delete ALL Text files from a directory using a php script.
I am trying o delete all zip and rar files from a specific directory.
I'm trying to delete my files folder from Internal Storage, but the code which
I'm trying to delete a directory that contains XML files from a remote computer.
I am trying to delete a files. I check the date and delete if
So at the moment I'm trying to delete files listed in the directory that
When trying to delete a directory (+ contents) and after reading the files inside,
I am trying to delete a specific directory from mY temp folder try {

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.