The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep string but also it will show the next 5 lines thepurple Shell Programming and Scripting 10 10-07-2008 08:03 AM
Processing a log file based on date/time input and the date/time on the log file primp Shell Programming and Scripting 4 03-16-2008 11:23 AM
grep time and date ayhanne Shell Programming and Scripting 8 01-06-2008 09:12 AM
How to replace all string instances found by find+grep umen Shell Programming and Scripting 0 12-06-2007 03:52 AM
Help needed - Replacing all date & time occurrences in a file with a string using Sed Hema_M Shell Programming and Scripting 4 11-17-2005 01:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-17-2008
woodstock woodstock is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 5
Lightbulb grep to show date/time of file the string was found in.

I’ve seen several examples of grep showing the filename the string was found in, but what I really need is grep to show the file details in long format (like ls -l would).
scenario is:
grep mobile_number todays_files

This will show me the string I’m after & which files they turn up in, but the string could show in several files, so being able to see the time the files were created & in time order would be handy in identifying the order of events rather than having to “ls –l” all the identified files after.
Eg
broken, still broken, fixed (good)
fixed, broken, still broken (bad)
I have tried combination of "-exec ls -ltr {} \;" but don’t seem to be getting anywhere.
  #2 (permalink)  
Old 12-17-2008
SFNYC SFNYC is offline
Registered User
  
 

Join Date: Jun 2008
Location: New York City
Posts: 95
Try:


Code:
grep -l searchstring filename(s) | xargs ls -l

  #3 (permalink)  
Old 12-17-2008
woodstock woodstock is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 5
Just the job

Thanks SFNYC. Just what I was after. Stick a “t” on the end & I can now see what happened to the numbers & in what order.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0