Shell script to write in a file

Discussion in 'Programming/Scripts' started by apenkov, Oct 17, 2010.

  1. apenkov

    apenkov New Member

    Can you please help me....I have that command
    awk '/Event/{cnt++}END{print cnt,"MBLR", $YESTERDAY}' ME_MBLR_$YESTERDAY* > counter.txt
    that writes in counter.txt and the result is:
    1234 MBLR
    how can I add one more column with the yesterday date? And result to be:
    1234 MOBILEROAM 20101016

    where $YESTERDAY=20101016

    Thanks in advance!!

  2. vikas027

    vikas027 New Member


    Suppose you below result is in variable ABC.
    1234 MBLR

    You can modify it as below
    echo $ABC | sed 's/MBLR/MOBILEROAM/' | sed 's/.*/& '`date -dyesterday  | awk '{print $6"-"$2"-"$3}'`'/'
    I have tested this in RHEL machine.

    Also, always use commands, scripts, e.t.c in CODE Tags while posting.
  3. apenkov

    apenkov New Member

    Thanks a lot!!

Share This Page