Solved

grep for portion of a line with specific syntax

Posted on 2012-03-22
7
298 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
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.:

707 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