Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    1

    Unanswered: Shell script to add 3 commas at the end of each line of a file

    Can anyone please help me in writing Shell script to add 3 commas at the end of each line of a file.
    Thanks.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You can use "sed":
    Code:
    cat inputFile | sed -e 's/(.*)/\1,,,/' > outputFile && mv outputFile inputFile
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    vim works nicely here:

    Code:
    vim '+:%norm A,,,' '+:wq' file
    To save it with a different name:

    Code:
    vim '+:%norm A,,,' '+:w newfile' '+:q!' file

Posting Permissions

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