The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Add string after another string with special characters heliode Shell Programming and Scripting 2 03-21-2008 05:06 AM
How to change only the x first characters of a string? Juha Shell Programming and Scripting 2 09-28-2007 05:17 AM
Removing characters from a string mh53j_fe Shell Programming and Scripting 3 06-03-2005 09:35 AM
Removing characters from end of $string craig2k Shell Programming and Scripting 3 03-25-2003 07:38 AM
removing characters from end of string el_toro Shell Programming and Scripting 4 07-14-2002 05:02 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 05-07-2008
Registered User
 

Join Date: Dec 2004
Location: Zürich
Posts: 146
I need to handle the following line:

192.168.0.0 - - [07/May/2008:11:42:31 +0100] "GET /images/top_line.gif HTTP/1.1" 200 51 "https://server.com/caches/themes/html/styles/All.css" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 WHE_SLS" "sbslang=; www-stats=11984687e55.1dd9a88; PD_STATEFUL_d796f17c-15c0-11dd-bb1e-c0a8580aaa77=%2Fwas; JSESSIONID=0000sSm-zPjR_Wd9ZG4yYwMBx7U:12cgh2sq9; sbsmwwindowlist.AGY=%5B%5B%2269848949%22%2C%220%22%2C%22default%22%2C%220%22%2C%221%22%2C%2207114231 051%22%2C%220%22%2C%221280%22%2C%22AGY%22%2C%22%22%5D%5D"

and extract the part marked in bold letters.
Reply With Quote
Forum Sponsor
  #9  
Old 05-07-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,314
Assuming the format is constant:

Code:
awk -F";" '{sub(".*:","",$8);print $8}'
Regards
Reply With Quote
  #10  
Old 05-07-2008
Registered User
 

Join Date: Dec 2004
Location: Zürich
Posts: 146
Unfortunately the format is not constant, the position of the JSESSIONID parameter varies.
Reply With Quote
  #11  
Old 05-07-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,924
Use nawk or /usr/xpg4/bin/awk on Solaris.

Code:
awk 'NF>1&&$0=$2' FS="JSESSIONID=[^:]*:" RS=";" input
Code:
perl -lne'print $1 while /JSESSIONID=.*?:(.*?);/g' input
Reply With Quote
  #12  
Old 05-07-2008
Registered User
 

Join Date: Dec 2004
Location: Zürich
Posts: 146
Ok, thanks! Both work.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0