Results 1 to 4 of 4

Thread: help in script

  1. #1
    Join Date
    Jun 2012
    Posts
    2

    Unanswered: help in script

    INPUT:1_120606259532_3_4.5_888

    if there any many inputs..in all the inputs the date length (bold) is constant ie 12 digits,i need 2 remove the last 4 digits in date field and replace with "9899" and finally the last segment in the file ie 888 needs to be removed.

    i need 2 write a script for this/

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Can you post a larger sample of the input?
    Are all lines the same length?
    Do you want the underscore before the "888" to be in the output?

  3. #3
    Join Date
    Jun 2012
    Posts
    2
    desired output :1_120606259532_3_4.5

    all lines are not same length only the daytimestamp that is the second element is constant.

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    IFS="_"
    while read a datexxxx b c d
    do
        dt=`echo $datexxxx |cut -c 1-8`
        echo $a"_"$dt"9899_"$b"_"$c
    done

Posting Permissions

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