Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all,
I have a text file and I want to clean up the file by only print those lines start with the date. Is there anyway I can do that?
Code:[?25h[2J[?4l[?1l[0m[1;24r[?3h[?3h
Wed Jun 1 2005 10:44AM
Page 1
SCAD
Location Log Recall Report
Tue May 31 2005 12:00AM to Tue May 31 2005 11:59PM
____________________________________________________________________________________________________ ______________________________
| |
| Locations: 656 SCAD FY101 Transactions: Valid Transaction Type: All Reader Status: Online |
|___________________________________________________________________________________________________ _______________________________|
| | |T| |Reader| | | |M|O|O| | Trans |
| Date | Time |P| Location | Name | ID Number | Cardholder Name | Action |N|F|K| Reason |Amount |____________________________________________________________________________________________________ ______________________________
|05/31/05|02:55PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|02:55PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|02:56PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|02:59PM|1|FY101 |FY101A| | |No Sale | | |Y| | |
|05/31/05|02:59PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|03:29PM|1|FY101 |FY101A| | |No Sale | | |Y| | |
|05/31/05|05:21PM|1|FY101 |FY101A|000668279 |MCNEAL,CORVET J. |SUMMER VALIDATIONS | | |Y| | |____________________________________________________________________________________________________ ______________________________
Blackboard Inc. End
[24;1H[K[?3l
[H[JThanks
CT

Hi all,
I have a text file and I want to clean up the file by only print those lines start with the date. Is there anyway I can do that?
[code][?25h[2J[?4l[?1l[0m[1;24r[?3h[?3h
Wed Jun 1 2005 10:44AM
Page 1
SCAD
Location Log Recall Report
Tue May 31 2005 12:00AM to Tue May 31 2005 11:59PM
____________________________________________________________________________________________________ ______________________________
| |
| Locations: 656 SCAD FY101 Transactions: Valid Transaction Type: All Reader Status: Online |
|___________________________________________________________________________________________________ _______________________________|
| | |T| |Reader| | | |M|O|O| | Trans |
| Date | Time |P| Location | Name | ID Number | Cardholder Name | Action |N|F|K| Reason |Amount |____________________________________________________________________________________________________ ______________________________
|05/31/05|02:55PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|02:55PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|02:56PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|02:59PM|1|FY101 |FY101A| | |No Sale | | |Y| | |
|05/31/05|02:59PM|1|FY101 |FY101A|000756582 |Perez, Luz Marina |SUMMER VALIDATIONS | | |Y| | |
|05/31/05|03:29PM|1|FY101 |FY101A| | |No Sale | | |Y| | |
|05/31/05|05:21PM|1|FY101 |FY101A|000668279 |MCNEAL,CORVET J. |SUMMER VALIDATIONS | | |Y| | |____________________________________________________________________________________________________ ______________________________
Blackboard Inc. End
[24;1H[K[?3l
[H[J
[/code]
ThanksCT

Hi,
You can use the syntax as given below:
cat <full_path_of_file> | egrep -i 'Sun|Mon|Tue|Wed|Thu|Fri|Sat'
You can also redirect the output the contents to a new log file using the > as redirection.
cat <full_path_of_file> | egrep -i 'Sun|Mon|Tue|Wed|Thu|Fri|Sat' > <newfile>
Hope it helps,
Rajesh

Rajesh,
In the text file i pasted above, I only need those lines start with |05/31/2005 to be printed. The data will be update periodically, so the date will change too.
ThanksCT

You can grep for lines that begin with a specific pattern such as:
grep '^|[01][0-9]/[0123][0-9]/[01][0-9]|'
That greps for dates through year 19.

You can use the same regex patterns in sed.
sed -n '/^|[0-1][0-9]\/[0-3][0-9]\/[0-9][0-9]/p' infile > outfile

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |