LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-01-2003, 10:39 AM   #1
dilberim82
Member
 
Registered: Apr 2001
Location: NY
Distribution: used to be Redhat, now Debian Sarge
Posts: 291

Rep: Reputation: 30
awk question


I am trying to write a program with awk. I have a file with
Name:Birthday:PhoneNumber:Email of my friends. I want to match the date of that month to the month of the birthday and e-mail that line to myself. Everything is done except i cannot match the date.
awk -F: '$2 == "03/11/1982" {print $1, $2, $3, $4} ' ./bd
works. But how can i match the first two numbers of birtday to date and print everything?
 
Old 10-01-2003, 11:39 AM   #2
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 32
cat bday.txt | awk -F : 'BEGIN{"date +%m"|getline month ; "date +%d"| getline num} { split($2,a,"/");if((a[1]==num)&&(a[2]==month)){print $1" "$2" "$3" "$4}}'

The output would be all the fields of those who have their birthdays today....
 
Old 10-01-2003, 07:12 PM   #3
dilberim82
Member
 
Registered: Apr 2001
Location: NY
Distribution: used to be Redhat, now Debian Sarge
Posts: 291

Original Poster
Rep: Reputation: 30
thx satan

It did not work the first time i tried but i got it to work... I had everything setup [month/date/year] so i had to switch month and num in your if statement.

Thanks alot .
 
  


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
awk question puishor Programming 2 08-26-2005 09:44 AM
awk question denalitastic Linux - Newbie 1 06-07-2005 10:42 AM
AWK question paraiso Linux - Newbie 5 05-12-2005 01:37 PM
awk question jonlake Linux - Software 2 05-04-2005 03:58 PM
awk question (mandrake 8.2) Frauke Linux - Newbie 0 09-19-2002 04:05 PM


All times are GMT -5. The time now is 08:49 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration