I am trying to use this script however it is not running well
the code does not display the first 10 lines of the file that I want to check
since after the file grow, it cannot grep "warning" as well
the code does not display anything.
tail -f is a continous tailing of a file and not displaying the 1st 10 lines of a file. That would be a simple
or
Also files usualy grow at the end of the file so you might want to be more precise if you want to check the latest 10 rows of a file or the 1st.
Rest of the grep is ok - but if it doesn't print anything it seems there is nothing in your file that matches.
The tail -f into a variable does not work since the defining of the variable does not end becuase the file you are tailing is kept open.
If you tell us what you want to do with the results inside a variable we can maybe show an alternative.
I want to put `tail -f filename | grep -i -E 'error|warning'` into a variable and construct an e-mail that report any lines that contain "error" or "warning", after that, I will send the mail to the address specified in the RECIPIENT shell variable which is defined within the script.
I have tried `tail -f filename | grep -i -E 'error|warning'` in the terminal, there is no problem that it displayed last(sorry it is not the 'first' I just posted) 10 lines of the file which contain "error" and "warning" firstly, and then wait for the file to grow and check the next line if it is contain the keywords.
also , the `grep -i -E 'error|warning'`, is it correct that it can grep all the "error" or "warning" in any combination of upper and lower case letters?
I use tail -f because the file the script check will grow, the task is to handle the growing content in the file.
but since using tail -f is not wise because I have no idea how to put it in to a variable.
Hi 2 all,
i have had AIX 7.2
:/# /usr/IBMAHS/bin/apachectl -v
Server version: Apache/2.4.12 (Unix)
Server built: May 25 2015 04:58:27
:/#:/# /usr/IBMAHS/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_worker_module (static)
... (3 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi All,
I'm completely new to bash scripting and still learning my way through albeit vey slowly.
I need to know where to insert my server names', my ip address numbers through out the script alas to no avail.
I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Hi all,
I was wondering why tail -n 2 filename produce an error when I manage to do similar command on head -n 2 filename
SunOS{type8code0}: tail -n 2 filename
usage: tail ]
tail ] (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
Is there some way I can have a script monitor the newest line of a log file until a certain entry gets placed in the log?
Basically I want to start this script, and have it spit up the last 10 lines or so to a browser via AJAX... the AJAX is not my problem though, as I have no idea how to go... (4 Replies)
Hi Everyone ,
I am facing a strange problem
i have made the follwing script to watch a appending log file (abc.log) but its not moving after the line tail -f ,
any suggestions
=====================================
#!/bin/bash
while true
do
tail -f abc.log | grep "exceptions"
echo hi... (12 Replies)