LinuxQuestions.org
Review your favorite Linux distribution.
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 07-06-2023, 07:59 AM   #16
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,866
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869

Don't do that, shell variables aren't meant to store file-contents.
 
Old 07-06-2023, 08:29 AM   #17
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,604

Rep: Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547Reputation: 2547

This appears to be your real problem...
Quote:
Originally Posted by pedropt View Post
... i am parsing the log files for anomalies ...
Quote:
Originally Posted by pedropt View Post
I was thinking in setting just 1 log variable as :

log="/var/log/nginx/access.log*"

but this will include also the gzip files inside nginx logs directory , witch are access.log.2.gz , etc... , and i do not want that .
The answer is to use --exclude, as described in "grep --help" (and man grep):
Code:
grep something /var/log/nginx/access.log* --exclude='*.gz'
Or simply use zgrep to decompress those files before searching them.

(p.s., use "[code]..[/code]" not "[quote]..[/quote]" when posting code.)

 
Old 07-06-2023, 08:50 AM   #18
pedropt
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 345

Original Poster
Rep: Reputation: Disabled
Thank you boughtonp and all others that helped on this issue , you guys and many others here are my salvation in many doubts i get when i am building scripts for my server or tools for other stuff here , Linuxquestions is an excellent forum , Thank you all not only for the help but also for the other alternatives solutions and code optimizations you guys help here .

Thank you
 
Old 07-06-2023, 09:20 AM   #19
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,798

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
One more:
Code:
#!/bin/bash
shopt -s extglob
grep something *.log!(*.gz)
grep -h ....
suppresses the filename: prefixing.
 
1 members found this post helpful.
  


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
[SOLVED] Search Directory full of txt files for a unique string imkornhulio Programming 8 12-13-2013 10:23 AM
[SOLVED] assign full name to variable then grep a file for the variable socalheel Programming 3 09-16-2013 11:04 AM
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
How to use grep to search for a specific variable.. memo007 Linux - Software 4 02-24-2007 05:52 PM

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

All times are GMT -5. The time now is 08:45 PM.

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