Solved

grep for portion of a line with specific syntax

Posted on 2012-03-22
7
296 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php56-php-mcrypt for rhel7 php56 1 111
need to create an dynamic distribution group based on division attribute 8 45
Unix Command (AIX) 3 42
Shell Script- gzip 5 50
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 …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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.

726 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