Thursday 21 May 2015

Write an awk script that accepts date argument in the form of dd-mm-yy and displays it in the form if month, day and year. The script should check the validity of the argument and in the case of error, display a suitable message.VTU MCA UNIX LAB10A

BEGIN{
printf("Enter date")
getline str<"/dev/tty"
split(str,a,"-")
   
    if(a[1]>0 && a[1]<=31)
    {
        if(a[2]>0 && a[2]<=12)
system("date +%B%t%A%t%Y -d "a[3]"-"a[2]"-"a[1]"")
    else
    printf("invalid month")
    }
    else
    printf("invalid date")
}

No comments:

Post a Comment