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

    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0

    String Concatination


    Hi


    I want to get a string in Shell script with the below format.

    log-10-03-2013_&_6h16m18s_QA.out

    10-03-2013 is current date.
    6h16m18s is current time.
    log ,QA and & are static

    I need the full information in string in a shell script file .

    I am a new to unix and can anybody help on this.

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,449
    Rep Power
    1751
    MyVar="log-$(date %+F)_&_$(date %+H+M+S)_QA.out"

    The date command for the time needs 'padding' to insert the h, m and s literals, but I'm not at a *nix command lien at the moment so cannot check.
    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