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

    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Constructing a file with date and time


    Hi
    I am a novice and have an existing script which creates a text file.
    I need to enhance it so that it will now print a one-line report via lp as follows :

    'On DD/MM/YYYY at HH:MM the following number of records were output : nn'

    where nn is the number of records in my file.

    I know I can get the value of nn via wc l,
    but do not know how to get the first part of the line with the date and time.

    Presumably I should be creating a fileA,
    and then cating fileA with a file with the contents
    of the wc l command,
    but unfortunately do not know how to create fileA.

    Any help would be most welcome !
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,439
    Rep Power
    1688
    You are ok with inserting the value of the number of records into the file, just repeat the same type of operation/function, but this time with suitable output from the date command:

    Code:
    runtime=$(date "+%x at %R")
    Note that the %x pre-supposes your locale date format is d/m/y. If it isn't it is simple enough to construct the right format.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0
    many thanks Simon : working great.
    sorry for the delay in response
    illness & vacation
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,439
    Rep Power
    1688
    Three reasons to be cheerful:
    you're feeling better
    it worked
    you had a good (hoepfully!) holiday
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo