0

My test.txt looks like this

drwx------+  5 dc staff   170 Jan 19 00:17 stopwords.txt
drwxr-xr-x   4 dc staff   136 Feb 20 21:15 test.pl
-rw-r--r--   1 dc staff   845 Feb 26 00:09 test.txt
-rw-r--r--   1 dc staff   917 Feb 26 00:45 test1.txt

I want to Extract those files which are created 1 week before the current date (when the shell script is run)

Debaditya
  • 2,419
  • 1
  • 27
  • 46

1 Answers1

3

Instead of parsing a text file with a directory contents, you could use find directly:

find <directory> -ctime +7

This will print all the files under <directory> that have been created more than 7 days ago.

For more information, please have a look at this related question.

Community
  • 1
  • 1
jcollado
  • 39,419
  • 8
  • 102
  • 133