Log Search Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log Search Script
# 1  
Old 08-05-2008
Log Search Script

Hi,

I am trying to write a script to search a log- IPaddress being the search criteria, I would ideally like the script to ask the ipaddress

Enter IP address - 244.258.27.225

And the ideal result would be for the script to get all the entries in the log file for a particular IP address,

  • echo -n "IP address ?
  • "read ip_addr
Please help me, Im new to scripting.


Thanks for your time
# 2  
Old 08-05-2008
Code:
echo "enter IP address:\c"
read ip
grep $ip logfile

Be aware that 244.258.27.225 has dots in it - there are some ways dots could change the search result because regular expressions use dots as a special character. If you run into problems check back here.
# 3  
Old 08-05-2008
Quote:
Originally Posted by jim mcnamara
Code:
echo "enter IP address:\c"
read ip
grep $ip logfile

Be aware that 244.258.27.225 has dots in it - there are some ways dots could change the search result because regular expressions use dots as a special character. If you run into problems check back here.
be sure to check greps manual page. in basic regular expressions the . (dot) dosnt have any special meaning (not at least acording to the manual page of my system with GNU grep 2.5.1 )
# 4  
Old 08-05-2008
Data Guessing that this is homework too...

Now, including this one, I see three of the same questions.
By rules, homework assistance is not allowed.

https://www.unix.com/shell-programmin...#post302221964

https://www.unix.com/shell-programmin...#post302221963
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script to search log file for last 15 mins data

Hi All, I have an issue which I'm trying to understand a way of doing, I have several nodes which contain syslog events which I want to force trigger an email initially (eventually leading to another method of alerting but to start with an email). Basically the syslog file will have hours worth... (6 Replies)
Discussion started by: mutley2202
6 Replies

2. Shell Programming and Scripting

Script to search for a pattern in 30 minutes from a log file

Hello All, I have to write a script which will search for diffrent patterns like "Struck" "Out of Memory" , etc from a log file in Linux box's. Now I will be executing a cron job to find out the results by executing the script once in every 30 minutes. suppose time is 14-04-29:05:31:09 So I... (3 Replies)
Discussion started by: Shubhasis Mathr
3 Replies

3. Shell Programming and Scripting

Log search and mail it if the log is updated before 24 hours from the current time

Hi , We have around 22 logs , each has different entries. I have to automate this using shell script. The ideas which am sharing is given below 1) We use only TAIL -100 <location and name of the log> Command to check the logs. 2) We want to check whether the log was updated before 24... (13 Replies)
Discussion started by: Kalaihari
13 Replies

4. Shell Programming and Scripting

How to search log file from a date

Hi All, I want to grep through all the log files created from 20th August. How do I do that? My script will run everyday. So it will take current date as To_Date. My log file name looks like - applog-2012-08-20-000001....applog-2012-08-20-000002...etc. Thanks in advance. (5 Replies)
Discussion started by: kmajumder
5 Replies

5. UNIX for Dummies Questions & Answers

How to search in a log file?

Hey guys, I'm still relatively new to Linux and everyday is a learning experience for me. Anyway, I have a question about searching inside a log file and didn't know what topic this would come under so posting it here as I am a Dummie lol! Say I have a log file which consists of say, for... (2 Replies)
Discussion started by: jimbob01
2 Replies

6. UNIX for Advanced & Expert Users

log search help

how to search a 4 GB log file for userid its creating a log file @ 4 gigs per 30 mins.. and the logs are rotating. . (2 Replies)
Discussion started by: robo
2 Replies

7. Shell Programming and Scripting

Search a pattern in a log file

I have file which gets updated every minute/second. Is it possible in shell scripting that I can search for some pattern infinitely in this file and if it finds that pattern, alert the user. A sample of log file is below. The following file is getting updated every second. I want to alert the... (2 Replies)
Discussion started by: Tuxidow
2 Replies

8. Shell Programming and Scripting

how to search reports with specified keyword in log

Hi, I have a question with sed/awk. When I handle some log files I want to search all reports with specified keyword. For example, in the log below. abcd efg ===start abc e ===end xyz ===start af f ===end nf ga ===start ab ===end (4 Replies)
Discussion started by: danielnpu
4 Replies

9. Shell Programming and Scripting

{How} Script to search a log file for a given criteria

I have to write a script to search the logfiles i.e msg.log for the following The Search Criteria is as follows 1. IP address 2. String Ex: abc.123.com 3. Timestamp ( start - end ) ex: 2008-05-04-00:30:00 - 2008-05-08-04:30:00 Can anyone help to devise a script for... (9 Replies)
Discussion started by: indiakingz
9 Replies

10. Shell Programming and Scripting

search log file

hi, I know this question probably been asked a thousand times but I can't find any posts that can help me out, so here I am. The problem is at the end of the day I want to execute a script but I only want to invoke it if and only if scripts 1/2/3/4/5/6 executed successfully. So what I did is to... (1 Reply)
Discussion started by: mpang_
1 Replies
Login or Register to Ask a Question