weissman
asked on
get dynamic parameter from text file
hi
i have a simple log text file (access_log ) that can have a url inside :
"POST / HTTP/1.1" 302 3064 "http://localhost/Succeeded.html?user=yyy" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
i want to get the user which is aftet "= " i mean yyy
the yyy is dynamic and other is state.
i have tried to use this:
username=`cat /access_log | grep -P '(?<=Succeeded.html?user=) [A-Za-z0-9 ]*'`
didn't work
please help
thanks a lot
i have a simple log text file (access_log ) that can have a url inside :
"POST / HTTP/1.1" 302 3064 "http://localhost/Succeeded.html?user=yyy" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
i want to get the user which is aftet "= " i mean yyy
the yyy is dynamic and other is state.
i have tried to use this:
username=`cat /access_log | grep -P '(?<=Succeeded.html?user=)
didn't work
please help
thanks a lot
ASKER
hi Dan,
thank you very much for helping i think it is almost perfect
the result is:
yyy "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
whrere yy is the user i need.
thank you very much for helping i think it is almost perfect
the result is:
yyy "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
whrere yy is the user i need.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks ... it give me the first occurance
I need the last ...can I use tail for that.
Thanks very much.
I need the last ...can I use tail for that.
Thanks very much.
username=cat /access_log | grep 'Succeeded.html?user=[A-Za
grep will retain only the lines where you have that link, while cut will give you the part after "="
LE: see here for a discussion on capturing groups with grep.
HTH,
Dan