![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
Assuming the format is constant:
Code:
awk -F";" '{sub(".*:","",$8);print $8}'
|
|
#10
|
|||
|
|||
|
Unfortunately the format is not constant, the position of the JSESSIONID parameter varies.
|
|
#11
|
||||
|
||||
|
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 |
|
#12
|
|||
|
|||
|
Ok, thanks! Both work.
|
|||
| Google The UNIX and Linux Forums |
| Tags |
| linux, solaris |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|