LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training 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 01-13-2015, 12:39 PM   #1
victordcweb
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Rep: Reputation: Disabled
replace lines matching a pattern


I have several files in that I need to add the text "N CHAR(1)," How can I accomplish this in linux without having to do it manually. Thanks

HAVE

nullcols
(A "to_number(:A,'9')"
,B CHAR(50)
)

WANT

nullcols
(N CHAR(1)
,A "to_number(:A,'9')"
,B CHAR(50)
)
 
Old 01-13-2015, 12:43 PM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
you need to check the command sed:
sed 's/<search string>/<replace string>/' filename is the syntax, you will need to set nullcols as <search string> and the two lines together as replacement.
see man page of sed for additional possibilities, flags and usage (or look for examples on the net).
 
  


Reply

Tags
sed bash


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
Scripting- sed command - replacing strings excluding the lines matching a pattern(s) msriram Linux - General 1 11-05-2012 10:29 AM
print pattern matching lines until immediate occurence of a character keerthika Linux - Newbie 7 04-11-2012 06:58 AM
[SOLVED] Replace pattern in specific lines and column with AWK cgcamal Programming 10 04-26-2010 02:11 AM
help extracting a matching pattern and next lines of match madvicious Programming 8 09-13-2009 02:01 AM
replacement with sed: replace pattern with multiple lines Hcman Programming 5 11-18-2004 08:40 AM


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