Need script logic


 
Thread Tools Search this Thread
Operating Systems Solaris Need script logic
# 1  
Old 03-15-2012
Need script logic

Hi,

i have a file which contains names of persons and date as below.

HTML Code:
peter 27-mar
Vicky  08-sep
Saryu 03-jan
venki  14-dec
.....
...
can someone plz provide a script logic, which returns the Name of the person whose date is matching with current date.
# 2  
Old 03-15-2012
Code:
$ today=$(date +%d-%a|tr "[A-Z]" "[a-z]")
$ echo $today
15-thu
$ grep "$today" input.txt

# 3  
Old 03-15-2012
Quote:
Originally Posted by itkamaraj
Code:
$ today=$(date +%d-%a|tr "[A-Z]" "[a-z]")
$ echo $today
15-thu
$ grep "$today" input.txt

Close, but %a gives the weekday not the month, you probably meant %b, and the translate can be avoided if you use ignore case option on grep:

Code:
grep -i "$( date +%d-%b )" input.txt


Last edited by agama; 03-15-2012 at 12:29 AM.. Reason: rewording
# 4  
Old 03-15-2012
oops.... i didnt notice properly Smilie
# 5  
Old 03-15-2012
Thank you all for the reply.

I tried the script and it returns the whole row. Is it possible to get Name alone ?
# 6  
Old 03-15-2012
Code:
 
today=$(date +%d-%b)
awk -v d="$today" '$0~tolower(d){print $1}' input.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need script logic

i have two csv files (rates.csv, reference.csv) as below. rates.csv contains Code, respective Zone details rates.csv ---------- 23,38Nhava 45,37NEWYORK 89,SHILANG 71,ROBACCA reference.csv contains all Zone details reference.csv ------------- 37Newyork robacca 38Nhava... (5 Replies)
Discussion started by: p_satyambabu
5 Replies

2. Shell Programming and Scripting

Script logic

Please help me to write the following script. 1) Input files will be in Test directory. (Test/YYYY/MM) folders (Ex: 1) 2010/ 01 2) 2011/05) The file name will be Testfile1_6676543218_Axxxxxxyyyyyzzzzzzzzzzzzzzzzzz.pdf.gz 2) The compare file will be in /tmp directory. (/tmp/comparefile.txt). The... (6 Replies)
Discussion started by: mnjx
6 Replies
Login or Register to Ask a Question