LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 06-23-2010, 07:05 PM   #1
mad_penguin
Member
 
Registered: Mar 2008
Posts: 69

Rep: Reputation: 15
bash dilema


Hi !

I'm planing to write a bash script that will make some web stats reports and I'm stuck on beginning because I don't know how can I read a directory content, put everything in a variable, compare the variable value with current date and go further.

More specific ...

I have /var/apache/log/. Here I have access logs on date ( like access.log.24.06.2010.gz and so on ).

How can I do to automatically zgrep (in a bash script) last day .gz ??


I look forward for your suggestions.

Thanks a lot.
 
Old 06-23-2010, 07:11 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I think you will need to give us some more information---including a sample of what the data (filenames?) looks like.
Quote:
...zgrep (in a bash script) last day .gz
What does this mean?
 
Old 06-23-2010, 07:20 PM   #3
mad_penguin
Member
 
Registered: Mar 2008
Posts: 69

Original Poster
Rep: Reputation: 15
For each day I have a archive that looks like download.2010-06-23.site.access.gz . I wish to read from another file, let say 'url_list' where I should have the url's I wish to zgrep and run the command for each URL in the $url_list but for the .gz file created one day behind.



Thanks!
 
Old 06-23-2010, 07:43 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well here is a lead into how you 'could' get the last file:
Code:
ls -lrt /var/apache/log/ | tail -n1 | awk '{print $NF}'
 
  


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
dilema blackbarron Linux - Newbie 5 02-08-2006 02:15 PM
my dilema Dunadan1821 Fedora 3 08-23-2004 04:33 PM
Yet another sound dilema danocars Mandriva 5 09-09-2003 10:21 PM
SLackWare 8.0 Dilema happylinux Linux - Distributions 2 03-29-2002 05:11 PM
eth1 dilema atari303 Linux - Networking 0 10-05-2001 04:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:04 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