Solved

grep for portion of a line with specific syntax

Posted on 2012-03-22
7
291 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
Comment Utility
Try this:
cut -d'/' -f4-6 filename

Open in new window

0
 

Author Comment

by:Justin_Edmands
Comment Utility
almost, strip off the end?
0
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
Comment Utility
With grep you could do something like

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

Open in new window

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Closing Comment

by:Justin_Edmands
Comment Utility
perfect.
0
 
LVL 31

Expert Comment

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

Open in new window

0
 

Author Comment

by:Justin_Edmands
Comment Utility
Thank you very much.
0
 
LVL 31

Expert Comment

by:farzanj
Comment Utility
Glad to help :)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
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.:

771 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

12 Experts available now in Live!

Get 1:1 Help Now