cancel
Showing results for 
Search instead for 
Did you mean: 
jeesshnasree
Starfighter Starfighter
Starfighter
  • 901 Views

for loop command display duration days files in Linux terminal

Jump to solution

Hello All,

 

 

Actually , I tried list out specific days  files with for loop in linux terminal .

Please find the below example & details :

 

Example :

2020

old year ex 2020 & days need to list out files from Feb 26 to Mar 6 2020


-rw-r--r--. 1 weblogic weblogic 0 Feb 26 2020 testing-1490.xls
-rw-r--r--. 1 weblogic weblogic 0 Feb 27 2020 testing-1489.xls
-rw-r--r--. 1 weblogic weblogic 0 Feb 28 2020 testing-1488.xls
-rw-r--r--. 1 weblogic weblogic 0 Feb 29 2020 testing-1487.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 1 2020 testing-1486.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 2 2020 testing-1485.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 3 2020 testing-1484.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 4 2020 testing-1483.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 5 2020 testing-1482.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 6 2020 testing-1481.xls

current year 2024 :
old year ex 2020 & days need to list out files from Feb 26 to Mar 6 2024

-rw-r--r--. 1 weblogic weblogic 0 Feb 26 2024 testing-1490.xls
-rw-r--r--. 1 weblogic weblogic 0 Feb 27 2024 testing-1489.xls
-rw-r--r--. 1 weblogic weblogic 0 Feb 28 2024 testing-1488.xls
-rw-r--r--. 1 weblogic weblogic 0 Feb 29 2024 testing-1487.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 1 2024 testing-1486.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 2 2024 testing-1485.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 3 2024 testing-1484.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 4 2024 testing-1483.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 5 2024 testing-1482.xls
-rw-r--r--. 1 weblogic weblogic 0 Mar 6 2024 testing-1481.xls

 

Please check help me command list out files some duration days files with for loop command in Linux teminal .

 

 

if possible print above mentioned scenario  with for loop then  please provide me command .

I mentioned above is exame & scenario .

if not poosible with for loop command for above mentioned criteria &  if  not possible with for loop then any specific alternative command meet above mentioned criteria .

I hope , explained issue clearly . Please check & provide me command if possible .

 

I am wairing for your valuable reply .

 

Thank you ,

 

JEESSHNASREE

 

1 Solution

Accepted Solutions
Chetan_Tiwary_
Community Manager
Community Manager
  • 871 Views

Hi @jeesshnasree !

Not sure what do you mean by this part of your post : 

Chetan_Tiwary__0-1711965729989.png

Why dont you try using "find" command for the purpose something like this : 

find . -type f -newermt "2020-02-26"  ! -newermt "2020-03-07"   and same for 2024 files. 

Here 26th Feb in inclusive whereas the 7th Mar is exclusive.

In this case for loop will be complex wherein you have to apply awk and if as well to list the files as per your scenario. 

Refer : https://man7.org/linux/man-pages/man1/find.1.html   search with newer 

Chetan_Tiwary__1-1711966453932.png

 

View solution in original post

2 Replies
Chetan_Tiwary_
Community Manager
Community Manager
  • 872 Views

Hi @jeesshnasree !

Not sure what do you mean by this part of your post : 

Chetan_Tiwary__0-1711965729989.png

Why dont you try using "find" command for the purpose something like this : 

find . -type f -newermt "2020-02-26"  ! -newermt "2020-03-07"   and same for 2024 files. 

Here 26th Feb in inclusive whereas the 7th Mar is exclusive.

In this case for loop will be complex wherein you have to apply awk and if as well to list the files as per your scenario. 

Refer : https://man7.org/linux/man-pages/man1/find.1.html   search with newer 

Chetan_Tiwary__1-1711966453932.png

 

jeesshnasree
Starfighter Starfighter
Starfighter
  • 834 Views

Thank you @Chetan_Tiwary_ ,

 

I thought it might be any possibility with for loop meet that activity .

Thank you for your valuable help & command . 

 

Thank you ,

JEESSHNASREE

Join the discussion
You must log in to join this conversation.