Shell script - add ) at the end of each line

Posted on 2012-08-22
Last Modified: 2012-08-27

What would be the sed commend to add a ) at the end of each line of a txt file that has 3M lines like this...

FileData(ORIGINATOR, 3343437)
CreateSubscription(){DestinationAddress(50522200010) Imsi(710210132268827
CreateSubscription(){DestinationAddress(50522200011) Imsi(710210132266017
CreateSubscription(){DestinationAddress(50522200012) Imsi(710210132266018
CreateSubscription(){DestinationAddress(50522200013) Imsi(710210132266019
CreateSubscription(){DestinationAddress(50522200014) Imsi(710210132266020
CreateSubscription(){DestinationAddress(50522200015) Imsi(710210132266021
CreateSubscription(){DestinationAddress(50522200016) Imsi(710210132266022

Question by:joaotelles
    LVL 31

    Accepted Solution

    sed 's/$/)/' filename

    Open in new window

    If you want to make permanent changes to the file use option -i

    sed -i 's/$/)/' filename

    Open in new window

    NOTE: Make sure you use sed without -i first and are happy with the output.
    LVL 31

    Expert Comment

    If you want to add ) at the end of lines with that start with CreateSubscription, then command would be:

    sed'/CreateSubscription.*/&)/' filename

    Open in new window


    Author Closing Comment


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
    The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now