Solved

Find characters between pattern in a file linux

Posted on 2016-09-01
3
44 Views
Last Modified: 2016-09-01
I have a file containing data like

10.222.3.124 - - [31/Aug/2016:00:00:00 +0100] DELETE /artefacts/content/repositories/trs-uta-releases/com/ac/fm/sc/arsing/arsing-du/1.0.4.22/ HTTP/1.1 204 -

I wan to list characters falling between "repositories/" and "/"
like in above example , it should give me
trs-uta-releases   only
0
Comment
Question by:Ravi Raj
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 41779559
STR='10.222.3.124 - - [31/Aug/2016:00:00:00 +0100] DELETE /artefacts/content/repositories/trs-uta-releases/com/ac/fm/sc/arsing/arsing-du/1.0.4.22/ HTTP/1.1 204 -'

echo $STR |  sed -e 's/^.*repositories\///' -e 's/\/.*//'

alternatively:

echo $STR | sed -e 's/^.*repositories\/\([^\/]*\).*/\1/'
0
 

Author Comment

by:Ravi Raj
ID: 41779565
Awesome , It worked for me, Ta!
0
 

Author Closing Comment

by:Ravi Raj
ID: 41779568
Awesome Solution
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now