LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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-26-2011, 06:20 PM   #1
Mojojo
Member
 
Registered: May 2003
Location: Philadelphia/PA
Distribution: Mint/Debian
Posts: 447

Rep: Reputation: 33
Need to add parentheses to 111,000 lines of txt?


The title is self explanatory I need to add parentheses to 111,000 lines of txt, How could I do this efficiently??? Instead of just placing a ( in front and a ) at the end of each line ;(
 
Old 09-26-2011, 06:31 PM   #2
Mojojo
Member
 
Registered: May 2003
Location: Philadelphia/PA
Distribution: Mint/Debian
Posts: 447

Original Poster
Rep: Reputation: 33
Answered my own question

Code:
sed -e 's/.*/\(&),/' test > test2
 
1 members found this post helpful.
Old 09-26-2011, 07:02 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,529

Rep: Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896
I am guessing you also needed a back slash and a comma too?
You can also change the original file using the -i option should you wish.
 
Old 09-26-2011, 07:10 PM   #4
Mojojo
Member
 
Registered: May 2003
Location: Philadelphia/PA
Distribution: Mint/Debian
Posts: 447

Original Poster
Rep: Reputation: 33
Its for an SQL Database, the backslash did not show in the test2 file though? This command gave me a ( in front and ), at the end. I would have used the -i option but I did not want to mess up the first file 111,000 lines of code is not worth starting over again on
 
Old 09-26-2011, 09:45 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,529

Rep: Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896
Well in addition you can also add a renaming to the original file, ie. -i.bak, this will allow for the file
with the original name to know have the newly formatted lines and file.bak to contain the old data.
 
  


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
cut first 10 lines of file master.txt and paste in ab1.txt and so on yogeshkumkar Programming 4 08-31-2011 07:23 AM
[SOLVED] Using AWK to print out the first few lines of a txt file mskalak Linux - Newbie 3 07-27-2011 02:58 PM
How do I get lines 30.000 to 40.000 from an Apache access_log file? Ujjain Linux - Newbie 5 03-27-2009 05:37 AM
Finding things on lines of a txt file Jayfrin Programming 3 05-15-2008 08:13 AM
IBM Contributes 500,000 Lines Of Code To Apache jamaso General 2 08-04-2004 11:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:50 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