LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-13-2012, 02:56 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Rep: Reputation: 30
adding 2 rows in a data file


Hello

I have this

/home/data.txt

I would add following 2 lines

name=test
name2=test2


below the line
@add@

which is already contained in /home/data.txt

How to do that using a linux command please ? I tried using echo or replace without success.

Thank you
 
Old 01-13-2012, 03:08 AM   #2
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
I am reading now that using the append function of sed could be helpful , please someone can show me how to use it in the example above ? Thank you
 
Old 01-13-2012, 03:16 AM   #3
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
ok I found http://www.unix.com/shell-programmin...ding-text.html
 
Old 01-13-2012, 11:41 AM   #4
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
this is what your looking for,pipe the output to a new file :

Quote:
sed '/@add@/ a\name=test \nname=test2/' data.txt
 
Old 01-13-2012, 12:14 PM   #5
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
yes , thank you!
 
Old 01-13-2012, 12:23 PM   #6
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
your welcome
 
  


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
Convert columns of data into rows jaufer Linux - Software 3 06-29-2010 05:19 PM
remove no data rows from a text file lothario Linux - Newbie 1 08-30-2009 07:18 AM
How to print data in rows and columns suran Linux - General 3 03-15-2009 02:53 PM
data with same number of rows and coloumns C/C++ fs11 Programming 2 04-29-2008 10:17 PM
Parsing rows and column data from a file using perl dav_y2k Programming 1 10-08-2006 11:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:33 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
Open Source Consulting | Domain Registration