0

I am genereting txt information with tcpdump. In output there is lots of information which contains something like that for instance:

Cookie: id=8xdza1ud39t459hv5bkth4t9gx71dicp; _ga=GA1.2.1890484279.1447252334; __gfp_64b=64smeVuOU7LSnfV8__mvHUkZFQF4lddYYY2X0c0HYAj.S7; __gads=ID=6ccc5cd620798f1a:T=1451575639:S=ALNI_MYeOVLFzU3qJTBxFq6KrdK10QDVrg; __utma=37331766.1890484279.1447252334.1451770396.1451770396.1; __utmz=37331766.1451770296.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); PHPSESSID=70c71a0c25d7d0425c657cee8f30dc2d; OX_sd=1; OX_plg=swf|shk|pm; _gat=1; _gat_newTracker=1; id=iyybhxg7524r2gcuvpguzvbse18c9c21

Is it possible to cut only this info from what i have and send it to another output? To match above cookie it needs to be a string which starts with "Cookie" ,ends with "id" atribute and contains "PHPSEESSID".

1
  • Can you show your sample input? Commented Jan 3, 2016 at 13:24

2 Answers 2

2

You coud try something like grep -E "^Cookie:.*PHPSESSID.* id=[^ ]+$".

It matches a line that

  • starts (^) with Cookie:
  • contains PHPSESSID (.*PHPSESSID.*)
  • and ends ($) with an id= field, due the [^ ] which prohibits spaces following the id=
Sign up to request clarification or add additional context in comments.

Comments

0

Use the grep command with there required regex to match

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.