Solved

grep for portion of a line with specific syntax

Posted on 2012-03-22
7
292 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

930 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

15 Experts available now in Live!

Get 1:1 Help Now