LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 11:39 AM   #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, 11:43 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
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



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 09:29 AM
print pattern matching lines until immediate occurence of a character keerthika Linux - Newbie 7 04-11-2012 05:58 AM
[SOLVED] Replace pattern in specific lines and column with AWK cgcamal Programming 10 04-26-2010 01:11 AM
help extracting a matching pattern and next lines of match madvicious Programming 8 09-13-2009 01:01 AM
replacement with sed: replace pattern with multiple lines Hcman Programming 5 11-18-2004 07:40 AM

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

All times are GMT -5. The time now is 04:39 PM.

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
Open Source Consulting | Domain Registration