Find the answer to your Linux question:
Results 1 to 3 of 3
hi i need to write a program that creates a file with name as current date and time as a file name every time i execute a progarm it should ...
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    27

    need help in creating a file

    hi
    i need to write a program that creates a file with name as current date and time as a file name

    every time i execute a progarm it should create a file with name current time and date

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    If your writing this program in C...just include the time.h header file and use the functionality included...

    #include <stdio.h>
    #include <time.h>

    int main(int argc, char**argv)
    {
    struct tm *ptr;
    time_t lt;

    lt = time(NULL);
    ptr = localtime(&lt);
    printf(asctime(ptr));

    return 0;
    }

    the rest you can figure out

  3. #3
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    And if you're scripting:

    >/tmp/myfile$(/bin/date +&#37;Y%m%d%H%M%S)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...