Solved

Find characters between pattern in a file linux

Posted on 2016-09-01
3
55 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

623 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