I am new to shell scripting. Need help on grep command. I had a file called file.log which contain below statements.
12 Nov 2013 14:12:17,756 INFO security - Userid: raja, Saved File Instance, Name: [SEIBEL], Registry: [RMV]
23 Nov 2013 14:14:11,777 INFO security - Userid: raja, Saved File Entry, Instance Name: [SEIBEL2], Entry Name: [RM_TO_RI857],Registry:
[RMV]
23 Nov 2013 14:14:11,777 INFO security - Userid: raja, Deleted File Entry, Instance Name: [SEIBEL2], Entry Name: [RM_TO_RI857],
Registry: [RMV]
In these i need to grep for 2 patterns "Saved" and "Deleted" and i need to copy the entire line(Not only the word) and append into a new file and need to send email. I tried the below but it doesnt work. Can some one help me please???
There is no error its creating a empty file logs(0 byte file). Instead i need the entire line to be copied to the file and same has to be sent o mails.
You are using the -q option on the grep's , which means "no output" . Another matter is, how you are going to capture the return code of the two commands and the > is overwriting the content every time grep is run, append instead:
So are you trying to do something like this:
--
Or do you want to run the second grep only when the first grep finds something and so the lines with "Saved" so not make it to the logs, as is the case now:
Last edited by Scrutinizer; 03-21-2014 at 02:54 AM..
Reason: Added some text about append
I need one more information. The file called file.log its updated everytime if some one have changed entry in tool. I just want to send an email everytime if file.log is updated with value saved or changed.
Basically my script need to run in background. If some one have updated then i need to recieve mail.
Can anyone help me??
/Thanks
---------- Post updated at 03:03 AM ---------- Previous update was at 01:24 AM ----------
If you want this script to be run every day then cron is the good option. Also for getting a mail when someone have changed file you need to add a extra condition in script by checking the last modification date of file.
This is just an suggestion, so please try and let us know if you have any queries.
Hi guys,
Hope someone can help me with this - I'm sure it's fairly simple but it's driving me mad! (forgive the coding - still new on scripting - come from Windows)
I have the following coding for checking whether I want to include a line in a file:-
EXTRACT_Date=$(date --date="${PERIOD}"... (6 Replies)
Hello, I have an input file that looks like so:
LDLR
LDLRAD4
VLDLR
when I grep "LDLR" I get an output of:
LDLR
LDLRAD4
VLDLR
Since all names have "LDLR" included within them, but all I want the output to be is
LDLR
I know it can work if I surround the words with pipes for... (5 Replies)
HI,
I have a command to check a license file.
License_print.
In that file you get the headlines and all different licenses.
Now i want to have things extracted from it.
so i do like following:
license_print | grep -iw -e "user" -e "admin"
But i donīt want all lines where user is... (11 Replies)
i have following pattern in file
s6:s2
s2:s4
s1:s2:s3:s4:s5:s6
s1
.
.
Now i want to find occurence of each record in file like s6:s2 occurs twice {once in first record and both occur in 3 record as well}
so output should be
s6:s2 2
s2:s4 2
s1:s2:s3:s4:s5:s6 :1
s1 : 2
... (7 Replies)
Hi All
I have a file containing following records:
$HEW_TGT_DB2_USER=hbme_bi2
$prmAttunityUser=ais
$DS_USER=hbme_bi2
$prmStgUser=hbme_bi2
$prmuser=hbme_bi2
$prmStgPass=hbme_bi2
$prmpwd=hbme_bi2
$prmAttunityUser=ais
Say suppose the name of the file is test4.txt
When i fire this... (2 Replies)
more Hello.txt
it was a sunny way and i was about to go home.
I need to grep and redirect to a new file all the text between 'sunny' and 'go' string above.
Note: There may be multiple lines in between the string i need to grep between. If there are multiple 'go' strings it should grep till... (9 Replies)
The below command is not working
stackmem="$(pmap $1 | grep -i '' | awk '{print $2}'| tr -d ' K')"
I need to grep strictly for ---->
Regards,
Mohtashim (2 Replies)
<record>
<set>
<termId>1234</termId>
<termType>First</termType>
</set>
<set>
<termId>5678</termId>
<termType>Second</termType>
</set>
</record>
This is saved in record.xml
Hi
I have this sample XML that i am grepping using a shell program.
The objective of the task is - based... (7 Replies)
using grep, i have a file emp.lst, and i want all those records
where "S" or "s" (capital or small) is not there
i used this
grep emp.lst
when i use grep emp.lst
i am getting rows with S..but why negate (^) is not working? (3 Replies)