Needed a help in inserting a new line!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Needed a help in inserting a new line!!!
# 8  
Old 12-01-2011
No.... Now the whole sed is not working... any other options? like with awk?
# 9  
Old 12-01-2011
can u show us the cmd u used and error it showed??
# 10  
Old 12-01-2011
Code:
sed i "/<group>/{G;G;}/" odcm.xml.

Since we cannot use -i for sed. When i'm not using the i option, its giving the result only in STDOUT, whereas when I use the i option with, i'm getting an error like:
Code:
'sed: Function i cannot be parsed.'


Last edited by Scott; 12-01-2011 at 09:22 AM.. Reason: Code tags
# 11  
Old 12-01-2011
sed -i ..., not sed i ....
# 12  
Old 12-01-2011
when i give the following command using sed -i giving an error like this:
Code:
sed: illegal option -- i
Usage: sed [-n] [-e script] [-f source_file] [file...]

---------- Post updated at 06:51 PM ---------- Previous update was at 06:49 PM ----------
Code:
sed -i "/<group>/{G;G;}/" odcm.xml:

This is the command i'm running.. without -i/i i'm getting the desired solution at the STDOUT, but i wanted to get the odcm.xml updated with the result...

Last edited by Scott; 12-01-2011 at 09:24 AM.. Reason: Use code tags, please...
# 13  
Old 12-01-2011
Then you'll need to use a temporary file, e.g.
Code:
sed 'stuff' odcm.xml > tempfile
mv tempfile odcm.xml

This User Gave Thanks to CarloM For This Post:
# 14  
Old 12-01-2011
Yes..datz de only way... I was trying out to do it without a temporary file.. It seems we can't get it done without temp file... Anywayz thanks all.... Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Inserting new line

Hi all, I want ot print a header with new line in the end. I am using echo like echo "this is header" I want output like This is header $ I tried -e also but it's not working. echo - e Can anyone help please? (6 Replies)
Discussion started by: dsa
6 Replies

2. Shell Programming and Scripting

Commenting a specific line and inserting a new line after commented line.

Hello All, I have following file contents cat file #line=aaaaaa #line=bbbbbb #line=cccccc #line=dddddd line=eeeeee #comment=11111 #comment=22222 #comment=33333 #comment=44444 comment=55555 Testing script Good Luck! I would like to comment line line=eeeeee and insert a new line... (19 Replies)
Discussion started by: manishdivs
19 Replies

3. Shell Programming and Scripting

Help with inserting a line

Hello, I am new to this forum. I have a question in Unix shell scripting. Here is my requirement I have 1000 files and I need to insert a header with one line at the top of each of the 1000 files. Please let me know if you have any solution for this Thanks in advance. Raj (4 Replies)
Discussion started by: trajashekar
4 Replies

4. Shell Programming and Scripting

Inserting a line in a file after every alternate line

Friends , I have a large file and i need to insert a line after every line.I am actually unaware how to do it.Any help appreciated. My File control station *ATM* , qread $OSS.Jul13A.FI01 interval 1 intcount 1 control station *ATM* , qread $OSS.Jul13A.FI02 interval 1 intcount... (4 Replies)
Discussion started by: appu2176
4 Replies

5. Shell Programming and Scripting

Inserting IP in one line of a file

Hi, I have this line: ip=111.222.133.144,mac=00:16:3E:2A:08:3C,vifname=veth360','ip=10.2.3.4,vifname=veth360a' ^ | ------- I want to insert this IP 144.133.222.111 between "144"... (4 Replies)
Discussion started by: iga3725
4 Replies

6. Shell Programming and Scripting

Inserting a line at the end

Hi All, I am using the below script to enter the URL at the end of file: echo "Enter the URL that should point to the particular microsite" read url sed "$a $url" redirects.virgin-atlantic.com.conf > temp But am getting the below error: ./script.sh:... (7 Replies)
Discussion started by: Shazin
7 Replies

7. UNIX for Advanced & Expert Users

Inserting a line before the line which matches the patter

Hi Is there any command where we can insert a line "2|||" before every line starting with "3|" my input is as follows 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 2|EN_GB||Electrogalvanize 0.5 m2 ( Renault ) 1|ETG|12345 3|88.51|||GBP|| desired output... (10 Replies)
Discussion started by: laxmi131
10 Replies

8. Shell Programming and Scripting

inserting a line after a perticular line

Hi, Suppose I have a file which contains many lines, ---------------------- wake up study hard play a little getting hungry <---- insert a line after this line watch TV go shopping come back home getting hungry <--- insert a line after this line listen music surf internet go to... (2 Replies)
Discussion started by: uday610
2 Replies

9. Shell Programming and Scripting

Inserting a new line

I have a file where each line starts with a "update" statement. I want to insert a new line, after each line, with the words "go" in the new line. Can someone help me out with this? (1 Reply)
Discussion started by: ssmallya
1 Replies

10. UNIX for Dummies Questions & Answers

inserting line??

guys can anyone tel me how to insert a line in a file(bash) using line number i wanna insert the line using LINE NUMBER...i know for inserting above or below a perticular line we can use sed a\ or i\.... thanks in advance.... (7 Replies)
Discussion started by: anj
7 Replies
Login or Register to Ask a Question