LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep a directory with date order (https://www.linuxquestions.org/questions/linux-newbie-8/grep-a-directory-with-date-order-704910/)

ust 02-15-2009 08:20 PM

grep a directory with date order
 
I want to grep a string from a directory , and the result is in date order , can advise what can i do ?

jschiwal 02-15-2009 08:31 PM

Sorry, but I don't know what you want to do. Do you want to extract a string from a directory listing?

If so, the include a directory listing fragment (or a full listing of a small directory) and show what parts you are interested in.
Two programs that are good at extracting information are sed and awk. Cut is also useful in cutting out just the columns you are interested in.

Look at the manpage for ls. There are different date formats you can use. There are also sorting options. You can begin with a directory list already sorted the way you want, and then extract the information you want.

---

If you are looking for a file who's filename contains a certain substring you are interested in, then you can use wildcard with ls, or use the find command.

Ranguvar 02-15-2009 08:32 PM

Sorry? What exactly? I'm guessing you want a list of files in a directory that have a certain string in them, sorted by date (modified? created?)?

ust 02-15-2009 08:42 PM

Quote:

Originally Posted by Ranguvar (Post 3444835)
Sorry? What exactly? I'm guessing you want a list of files in a directory that have a certain string in them, sorted by date (modified? created?)?

yes ,

that what I want to have sorted by created date, what can i do ? thx

jschiwal 02-16-2009 02:17 AM

There actually isn't a create date. The ctime reflects the time when the directory entry was changed. (status changed)
This could be from creating the time or just from altering the permissions.

Code:

ls --sort=time --time=
ls: ambiguous argument `' for `--time'
Valid arguments are:
  - `atime', `access', `use'
  - `ctime', `status'

Read the info manual for ls to determine which you want to use. --time=atime, --time=ctime or the default.
Use the -r argument to reverse the order.


All times are GMT -5. The time now is 01:36 AM.