Hi,
I have a variable called result
that get the the below value i.e two lines assigned.
./logs/mymac/myserver.log:####<Jun 7, 2015 12:56:54 PM EDT> <myserver.my.bank.com> <mymac> <[ACTIVE] ExecuteThread: '5' for queue:\
'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <1434640> <BEA-0900> <User user1 in security realm myrealm has had 5 invalid login attempts, locking account for 30 minutes.>
./logs/mymac/myserver.log:####<Jun 7, 2015 12:56:54 PM EDT> <myserver.my.bank.com> <mymac> <[ACTIVE] ExecuteThread: '5' for queue:\
'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <1434640> <BEA-0900> <User user7 in security realm myrealm has had 5 invalid login attempts, locking account for 30 minutes.>
Below is my code
result=$(find ./logs -type f -name "*.log" | xargs grep "BEA-0900")
for x in $result;
do
grep $x fail.log
if [ $? -eq 0 ]; then
echo "Value of x is:$x"
I am expecting the Value of x to be printed as
./logs/mymac/myserver.log:####<Jun 7, 2015 12:56:54 PM EDT> <myserver.my.bank.com> <mymac> <[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <1434640> <BEA-0900> <User user7 in security realm myrealm has had 5 invalid login attempts, locking account for 30 minutes.>
But, the value of x that it is currently populating is ./logs/mymac/myserver.log:####<Jun
and likewise it gets all values seperate by space when I wanted the value of x seperate by line.
Can you suggest what should be done ?
---------- Post updated at 10:54 AM ---------- Previous update was at 09:50 AM ----------
Please consider it resolved !! changed $x
TO "$x"