Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 10-01-2003, 11:39 AM   #1
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, 12:39 PM   #2
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 33
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, 08:12 PM   #3
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 .


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

All times are GMT -5. The time now is 10:48 AM.

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