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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:22:13+00:00 2026-05-11T05:22:13+00:00

We have a list of (let’s say 50) reports that get dumped into various

  • 0

We have a list of (let’s say 50) reports that get dumped into various folders depending on certain conditions. All the reports have standard names eg. D099C.LIS, D18A0.LIS etc.

Sometimes a report can exist in up to 5 different locations, and I need to generate a list of all the locations of the most recent version of each report.

I can do it easily using code, or redirecting ‘dir’ or ‘ls’ output into a text file and then manipulating it in Excel, but I’d prefer a simpler (hopefully a one-liner) solution either using DOS, bash, or PowerShell.

The best I’ve come up with so far in PowerShell (I’ve done something similar using bash) is:

ls -r -fi *.lis | sort @{expression={$_.Name}}, @{expression={$_.LastWriteTime};Descending=$true} | select Directory, Name, lastwritetime 

That will recursively list all files with *.lis extension, then sort it by name (asc) and date (desc), and then display the directory, name, and date.

This gives this sort of output:

C:\reports\LESE            D057A.LIS                  28/01/2009 09:00:43 C:\reports\JCSW            D057A.LIS                  27/01/2009 10:50:21 C:\reports\ALID            D075A.LIS                  04/02/2009 12:34:12 C:\reports\JCSW            D075B.LIS                  05/02/2009 10:07:15 C:\reports\ALID            D075B.LIS                  30/01/2009 09:14:57 C:\reports\BMA3            D081A.LIS                  01/09/2008 14:51:36 

What I obviously need to do now is remove the files that aren’t the most recent versions, so that the output looks like this (not too worried about formatting yet):

C:\reports\LESE            D057A.LIS                  28/01/2009 09:00:43 C:\reports\JCSW            D075B.LIS                  05/02/2009 10:07:15 C:\reports\BMA3            D081A.LIS                  01/09/2008 14:51:36 

Anyone have any ideas?

[edit] Some good ideas and answers to this question. Unfortunately I can’t mark all as accepted, but EBGreen’s (edited) answer worked without modification. I’ll add working solutions here as I verify them.

bash:

 ls -lR --time-style=long-iso | awk 'BEGIN{OFS='\t'}{print $5,$6,$7,$8}' | grep '.LIS' | sort -k4 -k2r -k3r | uniq -f3  ls -lR --time-style=long-iso | awk 'BEGIN{OFS='\t'}{print $5,$6,$7,$8}' | grep '.LIS' | sort -k4 -k2r -k3r | awk '!x[$4]++' 

PowerShell:

  ls -r -fi *.lis | sort @{expression={$_.Name}}, @{expression={$_.LastWriteTime};Descending=$true} | select Directory, Name, lastwritetime | Group-Object Name | %{$_.Group | Select -first 1}   ls -r . *.lis | sort -desc LastWriteTime | group Name | %{$_.Group[0]} | ft Directory,Name,LastWriteTime   ls -r -fi *.lis | sort @{expression={$_.Name}}, @{expression={$_.LastWriteTime};Descending=$true} | unique | ft Directory,Name,LastWriteTime 
  • 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-11T05:22:14+00:00Added an answer on May 11, 2026 at 5:22 am
    ls -r -fi *.lis | sort @{expression={$_.Name}}, @{expression={$_.LastWriteTime};Descending=$true} | select Directory, Name, lastwritetime | Group-Object Name | %{$_.Group | Select -first 1} 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

General question: Let's say you have a list of vertices that you pass into
Let's say I have a list of domain names that I would like to
I have list of lists. Let say somethink like that: somelist = [ [1,
Let's imagine that I have list of files at host1 find /path/to -name *.jpg
Let's say I have a list like this: <ul class=list> <li><span class=pos><div class=txt_pos>1</div></li> <li><span
Let's say I have a list of dictionaries: [ {'id': 1, 'name': 'john', 'age':
Let's say I have a list item and in each list item is a
Let's say I have a list of dicts. I define duplicates as any two
Let's say I have a list of primary keys, for each row one value
Let's say I have a list of words, something like this: ['The', 'Quick', 'Brown',

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.