How to append a string to the end of each line ?

I’ve got a SQL script file with no “;” in end of lines. This file has 500k lines.
Googling to find some help I’ve found two ways to solve:

1) using ‘sed’

sed -i ‘s/$/;/’ filename

2) using ‘vi’

:%s/$/;/g

I also found other ways to do same thing using Perl, Java, ….. but sed/vi is more quick and simple.

Advertisement

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.