Solved

Find characters between pattern in a file linux

Posted on 2016-09-01
3
46 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Squid Connection Pools 3 68
Postfix issues with spam/auth attempts under NAT 9 89
Bash Script to Analyze Oracle Schemas 11 105
Why  my code (program) build with old compiler? 11 47
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

777 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