Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    5

    Unanswered: Pls. HELP : How can I remove the last line, last char using shell script

    I have a file that I need to edit using shell script. The original file looks like this :


    '123456',
    '234567',
    '456789',

    This should be the expected output :
    '123456',
    '234567',
    '456789' <--- ( I just need to remove the (,) in the last line)

    Do you guys have any idea on how to do this? using an SH or KSH shell script?

  2. #2
    Join Date
    Feb 2004
    Location
    Los Angeles, CA
    Posts
    28
    You could just use the tr command :

    echo "456789," | tr ',' ' '

    It would change the comma into a space. That would be a quick easy way to do it.

  3. #3
    Join Date
    Oct 2003
    Posts
    5
    Quote Originally Posted by Bob4480
    You could just use the tr command :

    echo "456789," | tr ',' ' '

    It would change the comma into a space. That would be a quick easy way to do it.

    But I only need to change the last line and not all of them.

  4. #4
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    sed -e '$s/,$//' file
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

Posting Permissions

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