LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2009, 08:20 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
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 ?
 
Old 02-15-2009, 08:31 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
Old 02-15-2009, 08:32 PM   #3
Ranguvar
Member
 
Registered: Oct 2008
Location: Upstate NY
Distribution: Arch Linux
Posts: 99

Rep: Reputation: 17
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?)?
 
Old 02-15-2009, 08:42 PM   #4
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by Ranguvar View Post
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

Last edited by ust; 02-15-2009 at 09:00 PM.
 
Old 02-16-2009, 02:17 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.

Last edited by jschiwal; 02-16-2009 at 02:32 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the correct syntax order for tar with --after-date DATE, --newer DAT farhan Linux - General 1 03-16-2007 08:43 AM
problem with grep in root directory river_jetties Linux - Software 3 01-22-2007 01:10 PM
how to grep a specifc directory irfanhab Linux - General 3 12-19-2005 08:44 PM
logrotate log files - keeping in order when using grep or cat and bash dmellem Linux - Software 6 02-11-2005 01:05 PM
CD-ROM directory listing in JOLIET defined order. sombrabr Programming 0 01-29-2003 01:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration