Solved

Find characters between pattern in a file linux

Posted on 2016-09-01
3
41 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
Comment Utility
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
Comment Utility
Awesome , It worked for me, Ta!
0
 

Author Closing Comment

by:Ravi Raj
Comment Utility
Awesome Solution
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

10 Experts available now in Live!

Get 1:1 Help Now