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
Solved

grep for portion of a line with specific syntax

Posted on 2012-03-22
7
294 Views
Last Modified: 2012-08-14
I am having trouble trying to grep (or whatever is best) the date out of a specific output


499942634/1322025954/FFF035/11/23/2011 12:25:53 AM/full
3423594078/1326441742/FFF034/01/13/2012 02:37:07 AM/full


I was thinking use cut from position but the date is at two different positions in the two lines above.

Please let me know how to get that date!
0
Comment
Question by:Justin_Edmands
  • 4
  • 3
7 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 37755365
Try this:
cut -d'/' -f4-6 filename

Open in new window

0
 

Author Comment

by:Justin_Edmands
ID: 37755368
almost, strip off the end?
0
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
ID: 37755370
With grep you could do something like

grep -Po '\d\d\/\d\d\/\d{4}' filename

Open in new window

0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Closing Comment

by:Justin_Edmands
ID: 37755374
perfect.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37755380
Ok, Try this:
cut -d'/' -f4-6 filename | cut -d' ' -f1

Open in new window

0
 

Author Comment

by:Justin_Edmands
ID: 37755384
Thank you very much.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37755388
Glad to help :)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

790 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