LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-18-2009, 11:23 AM   #1
tucs_123
LQ Newbie
 
Registered: Dec 2008
Posts: 23

Rep: Reputation: 15
Replace every last closing bracket ) by );


Hi Guys,

Can any one help with the command for replacing every last closing bracket ) by );


My insert statements are as below:

INSERT INTO table(TP_CD,ABS_BATCH_ID) VALUES ('BT','AUTH')

and I want query as

INSERT INTO table(TP_CD,ABS_BATCH_ID) VALUES ('BT','AUTH');

Thanks in advance.
 
Old 09-18-2009, 11:31 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by tucs_123 View Post
Hi Guys,

Can any one help with the command for replacing every last closing bracket ) by );


My insert statements are as below:

INSERT INTO table(TP_CD,ABS_BATCH_ID) VALUES ('BT','AUTH')

and I want query as

INSERT INTO table(TP_CD,ABS_BATCH_ID) VALUES ('BT','AUTH');

Thanks in advance.
one way -

Code:
cat file | sed -e's/)$/);/g' > new_file
or in line

Code:
sed -i 's/)$/);/g' file

Last edited by centosboy; 09-18-2009 at 11:33 AM.
 
Old 09-18-2009, 11:31 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

sed -i 's/)$/);/' <infile>

This looks for a ) at the end of a line ($) and replaces it with );.
The -i changes it in place (original file is changed).

Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PS1 bracket expressions? JimHughen Linux - Software 7 06-17-2009 02:45 PM
URLs ending in a bracket ) aren't parsed properly pwc101 LQ Suggestions & Feedback 2 06-12-2009 10:50 AM
Tournament Bracket anamericanjoe General 1 09-19-2006 05:50 PM
Tcl/Tk Bracket Problems in Command Kenji Miyamoto Programming 0 06-27-2005 12:29 AM
Non-functioning bracket-key dekket Linux - General 1 04-21-2004 07:46 PM


All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration