Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Unanswered: using scripting language add a "*/" in a file

    Please I need help. I want to add "*/" in a file. Here is an example of what i would like to achieve.

    12345
    6789
    0987
    654

    I want to add "/*" at the start of 12345 and then add "*/" at the end of 0987.

    I would apprecaite if anyone can help me out in this.

  2. #2
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    138
    Hi bunnyG,
    I do not know what you realy want.
    I hope this solution can help you out



    # using scripting language add a "*/" in a file


    FO="dbforum12.org" #FILE_ORIGINAL
    FN="dbforum12.new" #FILE_NEW

    BS="12345" #BEGIN_STRING to add "/*"
    ES="0987" #END_STRING to add "*/"

    cat $FO | awk -v BS=$BS -v ES=$ES -v FN=$FN ' BEGIN { FS="@";OK=0 }
    {
    OK = 0
    if ($1 == BS )
    {
    print "/*"$1 > FN
    OK=1
    }
    if ($1 == ES )
    {
    print $1"*/" > FN
    OK=1
    }
    if (OK == 0 )
    {
    print $1 > FN
    }
    }'
    Greetings from germany
    Peter F.

  3. #3
    Join Date
    Dec 2004
    Posts
    2

    Thumbs up Thank you

    Thank you Peter ,

    A life saver, I will try this and will let you know. Thanks once again for the help


Posting Permissions

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