Yeah! It will work, but the user will get confuse when giving the sapce between date,month,year. I mean they generally give date as 12122010 instead of 12 12 2010. Now gimmi some idea how to specify the fixed place to the date fields i.e.,
as soon as the user enters DAY number it should jump into the MONTH field and then next to YEAR field. Screen display as following...
Enter date as dd mm yyyy : <DAY> / <MONTH> / <YEAR>
I did something different using awk, but it is also almost same like your solution....
clear
read -p " Enter Date as ddmmyyyy : " dat
awk '{
dd=substr('$dat',1,2);mm=substr('$dat',3,2);yy=substr('$dat',5,4);
sub(/00\/00\/0000/,dd"/"mm"/"yy,$0)
print $0
}' infile > outfile
but my request is there should be only
2 digit place for day
2 digit place for month
4 digit place for year
Last edited by visitnag; 01-30-2010 at 10:17 AM.
|