tail and redirect until finding a specific word


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tail and redirect until finding a specific word
# 1  
Old 12-02-2010
PHP tail and redirect until finding a specific word

Hey guys,
I'm a new bee to this forum as well as to Unix, just having a requirement which i'm not sure how to write shell script for it..

Here is my requirement

This is related to tomcat catalina.out file. Just want to display the content of this file until it finds a word like 'server started'. Once we get this line in catalina.out, tail -f catalina.out should be terminated. Not sure how to do it.


Any advice would be appreciated.

Thanks
# 2  
Old 12-02-2010
Code:
#!/bin/bash

tail -f filename | while read LINE
do
        [[ "${LINE}" == *"server started"* ]] && break

        echo "$LINE"
done

if you don't have bash, ksh should work too. plain sh might not.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 12-02-2010
MySQL

Perfect! It worked well.... Thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

2. Shell Programming and Scripting

How to print multiple specific column after a specific word?

Hello.... Pls help me (and sorry my english) :) So I have a file (test.txt) with 1 long line.... for example: isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh How to print after the "error" word the 2nd 4th 5th and 7th word?? output well be: 653 isfbisfb... (2 Replies)
Discussion started by: marvinandco
2 Replies

3. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

4. Shell Programming and Scripting

Fetch entries in front of specific word till next word

Hi all I have following file which I have to edit for research purpose file:///tmp/moz-screenshot.png body, div, table, thead, tbody, tfoot, tr, th, td, p { font-family: "Liberation Sans"; font-size: x-small; } Drug: KRP-104 QD Drug: Placebo Drug: Metformin|Drug:... (15 Replies)
Discussion started by: Priyanka Chopra
15 Replies

5. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

6. Shell Programming and Scripting

Display Specific line number using tail command

Hi , 1)i want to display specific line number using tail command. e.g. display 10 line from end. Please help... 2)Want to display line 10 to 15 (from end)using tail command) (2 Replies)
Discussion started by: vivek1489
2 Replies

7. UNIX for Dummies Questions & Answers

How to Tail for a specific string

Hi guys i am tailing a constantly appending log file. However, I am looking for some specific word to be seen only when there is an update. How should I look for the word "{test-0101}" in tail, so that it only shows when there is a line that contains {test-0101} ? Thanks (1 Reply)
Discussion started by: DallasT
1 Replies

8. Shell Programming and Scripting

Finding a specific word

Hi, I am trying to develop a script which should find a word if a particular word exists. Below is the content of the file. insert_job: test_job ----> job name days_of_week: all start_times: "16:00" date_conditions: 1 insert_job: test_job2 ----> job name days_of_week: all... (16 Replies)
Discussion started by: rpatty
16 Replies

9. Shell Programming and Scripting

Finding a word at specific location in a string

Hi All , I have different strings (SQL queries infact) of different lengths such as: 1. "SELECT XYZ FROM ABC WHERE ABC.DEF='123' " 2. "DELETE FROM ABC WHERE ABC.DEF='567'" 3. "SELECT * FROM ABC" I need to find out the word coming after the... (1 Reply)
Discussion started by: swapnil.nawale
1 Replies

10. Shell Programming and Scripting

redirect the next line after a word

hi All, I have one file: gain an overview. sue the swquesces. capture 333.captured tesh the values in the history. There may be something. caputure 111.done Then there is nothing everything is going on. Again there is. capture 222.ok I want the output as : 333.captured 111.done... (6 Replies)
Discussion started by: javeed7
6 Replies
Login or Register to Ask a Question