LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2010, 03:33 PM   #1
puth
LQ Newbie
 
Registered: Feb 2010
Posts: 19

Rep: Reputation: 0
help with inserting mutiple lines usign sed


hi,
i am trying to insert multiple lines in a file using sed.

suppose below is the text.
hi i am here.
Please "$x" me.
linuz forums.

i tried using
sed "`expr $line + 3` i\ hi i am here. \ Please "$x" me." ~/scripts/temp.txt

The entire output appeared in a line.
let me know how to print the text in multiple lines.

Last edited by puth; 02-11-2010 at 04:05 PM. Reason: USed \n instead of \ and now the text is printing in multiple lines
 
Old 02-13-2010, 06:45 AM   #2
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 99
I just noticed your last edit. Does that mean you figured it out?

If so, would you post what works in case someone else has the same
problem and would like to see the fix?
 
Old 02-13-2010, 03:40 PM   #3
puth
LQ Newbie
 
Registered: Feb 2010
Posts: 19

Original Poster
Rep: Reputation: 0
i already mentioned the solution used to resolve the issue in my comments.
Anyways i used \n instead of \ in my statement for printing the text in multiple lines.
 
  


Reply



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
Inserting Multiple Lines (with newline) using sed or awk hal8000b Programming 1 03-08-2009 05:21 PM
Sed command to print matching lines and 2 lines above.. DX398 Programming 12 10-01-2008 08:25 AM
how to use sed to delete mutiple string patterns from apache access log matyu Programming 3 01-05-2008 11:42 PM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM
Inserting Text into Mutiple HTML Files patisawsome Linux - Software 2 12-28-2005 01:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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