#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    2
    Rep Power
    0

    how to grep date format ddmmyyyy


    can anyone help me in this:
    I had to select file names in ddmmyyyy format from a list & have to make sure that selected file name should all the limitations of date,month & year such as date cannot exceed 31,30 or 28 depending upon the month.
  2. #2
  3. No Profile Picture
    ......@.........
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Posts
    1,345
    Rep Power
    56
    try:
    Code:
    while read filename
    do
    # validate date/time a parameter entered
      MMDD=$(expr substr $filename 5 4)
      YYYY=$(expr substr $filename 1 4)
      hh="01"
      mm="01"
      ss="01"
      if touch -c -t $YYYY$MMDD$hh$mm.$ss dummyfile
      then
         echo "$filename is valid"
      else
         echo "$filename is invalid"
    
       fi
    
    done  < listfile
    where listfile is a list of filenames

IMN logo majestic logo threadwatch logo seochat tools logo