LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-09-2012, 04:13 PM   #1
springjer10
LQ Newbie
 
Registered: Nov 2012
Posts: 1

Rep: Reputation: Disabled
A script that prints an event for a given date.


I would like to write a scipt that takes a given date as as argument and prints to screen a number of events listed for that day.

For example I have a database of events (.txt file) that are of the form "12/12/12 :Jane's Birthday". I would like to write a script that takes the input "12/12/12" and returns the output "Jane's Birthday". I understand how to write a script that prints the entire database of dates and events but I do not know how to selectively print an event for a given date. Would anyone have any examples I could follow? Many thanks.
 
Old 11-09-2012, 04:19 PM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by springjer10 View Post
I would like to write a scipt that takes a given date as as argument and prints to screen a number of events listed for that day.

For example I have a database of events (.txt file) that are of the form "12/12/12 :Jane's Birthday". I would like to write a script that takes the input "12/12/12" and returns the output "Jane's Birthday". I understand how to write a script that prints the entire database of dates and events but I do not know how to selectively print an event for a given date. Would anyone have any examples I could follow? Many thanks.
Try grep. For example,
Code:
grep "^12/12/12" file.txt
will print all lines from file.txt that begin with the string "12/12/12"
 
Old 11-10-2012, 02:32 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
I don't think you need to reinvent the wheel. You might want to check out the calendar application, which appears to do pretty much exactly what you describe. On debian it's provided in the bsdmainutils package.

Caveat: I've never actually used it myself.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
run script when a users prints Elcrapocrew Linux - Desktop 2 06-28-2010 05:45 PM
Looking for a shell script that prints a file only if it has more than 10 lines djfog Linux - Newbie 8 07-01-2008 01:23 PM
shell script to find modified date and last accessed date of any file. parasdua Linux - Newbie 6 04-22-2008 10:59 AM
cups prints poorly, while lpr from command line prints well spindles Linux - Software 2 04-01-2006 05:02 AM


All times are GMT -5. The time now is 02:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration