I'm trying to do this task The purpose of this task is to find bots inside huge logfile.
Lots of bots logged in to our service. They all do same thing very quickly, they log in, change password and log off all within one second. We want to find them in log.
also i want to write command in bash that will show all profiles meeting following criteria:
extract a specific data from log.txt
user logged in, user changed password, user logged of within same second (all 3 actions have to be done within 1 second) those actions (log in, change, log off) happend one after another with no other entires in between
fxsciaqulmlk - is typical profile name from the log file
small part of the log file
[a lot of data]
Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|fxsciaqulmlk| - |user logged in| -
Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|fxsciaqulmlk| - |user changed password| -
Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|fxsciaqulmlk| - |user logged off| -
Mon, 22 Aug 2016 13:15:42 +0200|178.57.66.225|faaaaaa11111| - |user logged in| -
Mon, 22 Aug 2016 13:15:49 +0200|178.57.66.215|terdsfsdfsdf| - |user logged in| -
Mon, 22 Aug 2016 13:15:49 +0200|178.57.66.215|terdsfsdfsdf| - |user changed password| -
Mon, 22 Aug 2016 13:15:49 +0200|178.57.66.215|terdsfsdfsdf| - |user logged off| -
Mon, 22 Aug 2016 13:15:59 +0200|178.57.66.205|erdsfsdfsdf| - |user logged in| -
Mon, 22 Aug 2016 13:15:59 +0200|178.57.66.205|erdsfsdfsdf| - |user logged in| -
Mon, 22 Aug 2016 13:15:59 +0200|178.57.66.205|erdsfsdfsdf| - |user changed password| -
Mon, 22 Aug 2016 13:15:59 +0200|178.57.66.205|erdsfsdfsdf| - |user logged off| -
Mon, 22 Aug 2016 13:17:50 +0200|178.57.66.205|abcbbabab| - |user logged in| -
Mon, 22 Aug 2016 13:17:50 +0200|178.57.66.205|abcbbabab| - |user changed password| -
Mon, 22 Aug 2016 13:17:50 +0200|178.57.66.205|abcbbabab| - |user changed profile| -
Mon, 22 Aug 2016 13:17:50 +0200|178.57.66.205|abcbbabab| - |user logged off| -
Mon, 22 Aug 2016 13:19:19 +0200|178.56.66.225|fxsciulmla| - |user logged in| -
Mon, 22 Aug 2016 13:19:19 +0200|178.56.66.225|fxsciulmla| - |user changed password| -
Mon, 22 Aug 2016 13:19:19 +0200|178.56.66.225|fxsciulmla| - |user logged off| -
Mon, 22 Aug 2016 13:20:42 +0200|178.57.67.225|faaaa0a1111| - |user logged in| -
[a lot of data]
so I wrote this code :
#!/bin/bash
log="/home/indra/Desktop/log.txt"
result="/home/indra/Desktop/bots.result"
> $result
while read line; do
date=`echo "$line" | cut -d' ' -f1-5`
ip=`echo "$line" | cut -d'|' -f2`
user=`echo "$line" | cut -d'|' -f3`
event=`echo "$line" | cut -d'|' -f5`
echo "date:$date user:$user from ip:$ip $event" >> "$results"
done < "$log"
but when I try to run this code I get this massage :
indra@indra-PC:~$ bash '/home/indra/Desktop/shtry/try3.sh'
/home/indra/Desktop/shtry/try3.sh: line 22: : No such file or directory
How to fix this? I'm a beginner in bash