LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-21-2007, 10:05 AM   #1
RobHill
LQ Newbie
 
Registered: Mar 2007
Posts: 7

Rep: Reputation: 0
How do I search for files in the past?


I am trying to write a shell script and in the script I have to look for an id in a file and look for that id in the files for the past 7 days. The file is gzipped after 24 hours. Any suggestion?
 
Old 05-21-2007, 10:16 AM   #2
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 196

Rep: Reputation: 31
Quote:
Originally Posted by RobHill
I am trying to write a shell script and in the script I have to look for an id in a file and look for that id in the files for the past 7 days. The file is gzipped after 24 hours. Any suggestion?
Do you think you could clarify what you are looking for? Perhaps even show the data that you need to find in the files?
 
Old 05-21-2007, 10:26 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 237Reputation: 237Reputation: 237
Quote:
Originally Posted by RobHill
Any suggestion?
read up on sed/awk/grep/gzip/tar and the find command. then try to write it. if you hit problems, come here again. just some examples to get you started,
Code:
# grep 'id' file #search for the id in file
# awk '/id/{print}' file
to unzip a file
Code:
# gzip -d file.gz
# tar zxvf file.tar.gz #if its also tarred.
to find txt files more than 7 days
Code:
find /path -type f -name "*txt" -mtime +7 -print
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I best search HTML files? vees Programming 7 03-20-2007 10:50 PM
To search for files of a particular size mufy Linux - General 1 12-09-2004 12:44 AM
Search for Files vs. ls albean Linux - Newbie 2 11-14-2004 02:35 PM
show files past a certain date vrillusions Linux - General 2 01-01-2004 08:08 PM
can i search for files from the console? Chooco Linux - General 13 06-04-2002 12:24 PM


All times are GMT -5. The time now is 03:19 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration