help using read in menu script to cat out lines in logs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help using read in menu script to cat out lines in logs
# 8  
Old 09-24-2009
So easy and I tried the stupid curly brackets and every combination but the one you showed. Thanks so much.
# 9  
Old 09-24-2009
Quote:
Originally Posted by dr.house
Code:
cat junk.log | grep '[hello|this]'

You just win the Useless Use of Cat Award Smilie

Code:
# grep '[hello|this]' junk.log
# grep "hello\|this" junk.log

# 10  
Old 09-24-2009
My script is almost done! Thanks everyone for your help and support.

---------- Post updated at 01:32 PM ---------- Previous update was at 09:49 AM ----------

Sorry, it was working fine. Then my boss had me change the words in the grep from error to failure and now its acting totally bizarre.

Code:
[root@current]# grep -i '[exception|fail]' demo-sam*.log|sort -u |more

Code:
6161]
2009/266 03:18:13.437: DEBUG snas.sam.MocClientAcceptor-36:processClientRequest(line 1414) - Received obj: DataRequest:13953921
2009/266 03:18:13.438: DEBUG snas.sam.MocClientAcceptor-36:sendObject(line 2226) - !!Transmitted Object Complete {user:mocuser1}: DataRequest:13953921
2009/266 03:18:43.451: DEBUG snas.sam.MocClientAcceptor-36:processClientRequest(line 1414) - Received obj: DataRequest:381753
2009/266 03:18:43.452: DEBUG snas.sam.MocClientAcceptor-36:sendObject(line 2226) - !!Transmitted Object Complete {user:mocuser1}: DataRequest:381753
2009/266 03:19:03.440: DEBUG snas.sam.MocAlertSveAcceptor-7:processMocResponse(line 298) - Received NativeData with key: Nat_ops_0000_207
2009/266 03:19:03.440: DEBUG snas.sam.MocAlertSveAcceptor-7:processMocResponse(line 299) - **** Native Type: Nat_ops_0000_207, Size: 901
2009/266 03:19:03.441: ERROR snas.sam.MocServiceManager:publishNativeData(line 525) - Native Data is not registered. Dropped Nat_ops_0000_207
2009/266 03:19:03.564: DEBUG snas.sam.MocAlertSveAcceptor-7:resetObjOutputStream(line 286) - <Threshold Reset> OutputStream reset - I/O messages: [37700, 1]
2009/266 03:19:04.560: DEBUG snas.sam.MocAlertSveAcceptor-7:processMocResponse(line 298) - Received NativeData with key: Nat_ops_1000_209
2009/266 03:19:04.560: DEBUG snas.sam.MocAlertSveAcceptor-7:processMocResponse(line 299) - **** Native Type: Nat_ops_1000_209, Size: 6963


Last edited by vgersh99; 09-24-2009 at 02:37 PM.. Reason: code tags, PLEASE!
# 11  
Old 09-24-2009
Quote:
Originally Posted by taekwondo
now its acting totally bizarre
In what particular way? - I take it that what you posted is the output you're currently getting, but what about the input (read: log file) you're starting from? Could you please show as an excerpt from that as well ...
# 12  
Old 09-24-2009
Did you try:
Code:
grep -i "exception\|fail" file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. Shell Programming and Scripting

Script to read last 30mins logs

Hi All, I want to read the log file for last 30mins logs with time stamps. Am using below command but, it is not working for me awk -F - -vDT="$(date --date="30 minutes ago" "+%b %_d %H:%M:%S")" ' DT < $1' log.file >tmp.txt log file time format is 2016-09-27 14:00:25,192 Use code... (1 Reply)
Discussion started by: Prashanth.K
1 Replies

3. AIX

Script to Read lines and print

Dears, I am trying to write a script to read the lines from a file in AIX Server. Below are the contents of the file. To explain, first part before = is path and second part is number. i am trying to write the script to print the path and count where count>100. any help must be appreciated... (3 Replies)
Discussion started by: sibbala
3 Replies

4. Shell Programming and Scripting

script to constantly read the last 500 new logs in a log file

Hello, I would like to write a bash script that would monitor a log file for a certain number of logs, let's say 500 logs and when it reaches that number to write the last log to another file. For example, I want to watch the /var/adm/messages and everytime, there is 500 new logs that are... (1 Reply)
Discussion started by: Pouchie1
1 Replies

5. Shell Programming and Scripting

Why does my script only read two lines of a file and not the third

I'm learning about the read command and wrote this little script to read data from a file: readfile() { while read variable; do echo $variable done } readfile < File.txt I have three lines in File.txt; each a single word. The script only echoes the first two lines and drops the... (9 Replies)
Discussion started by: Straitsfan
9 Replies

6. Shell Programming and Scripting

Menu in Menu script issue

Problem: I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Discussion started by: iDdraig
1 Replies

7. Shell Programming and Scripting

Read files, lines into array, cat vs open

Hi Everyone, I have a file: a.txt a,b,c,d,6,6,6 1,2,3,d,6,6,6 4,5,6,6,6,6,6 #!/usr/bin/perl use warnings; use strict; my @array = (); ### Load file into array for my $i (split '\n', `cat /tmp/a.txt`) { push @array, ; } It works. But my a.txt have 1million lines, and... (2 Replies)
Discussion started by: jimmy_y
2 Replies

8. Shell Programming and Scripting

Help parsing logs maybe with menu and variables?

I would like to parse through some logs looking for things like exception or failed (grep -i failed). Ideal would be if it were in a menu format so someone without unix ability could just choose option 1 2 or 3 etc. If I could pass the hostname to a variable also that would be awesome, so someone... (5 Replies)
Discussion started by: taekwondo
5 Replies

9. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

10. Shell Programming and Scripting

cat file1 read line-per-line then grep -A 15 lines down in fileb

STEP 1 # Set variable FILE=/tmp/mainfile SEARCHFILE =/tmp/searchfile # THIS IS THE MAIN FILE. cat /tmp/mainfile Interface Ethernet0/0 "outside", is up, line protocol is up Hardware is i82546GB rev03, BW 100 Mbps Full-Duplex(Full-duplex), 100 Mbps(100 Mbps) MAC address... (6 Replies)
Discussion started by: irongeekio
6 Replies
Login or Register to Ask a Question