SED - replace with new line didnīt work for solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED - replace with new line didnīt work for solaris
# 1  
Old 04-27-2009
Question SED - replace with new line didnīt work for solaris

Hi

This is what I was trying to do, comment one line and add something different in a new line right next.
This is the command I want to do
Code:
more .profile | sed 's,STRING1, #STRING1 NEWLINE STRING2,'

(Iīm using ',' because my string is something like this
exec /XXX/scripts/CRAZYERP/logins_restriction.sh -l
)

So the result will be
original file ( I will find 1)
Code:
1
2
3

modified file
Code:
#1
string2
2
3

I tried n and > but didnīt work too.

I found the this topic

https://www.unix.com/shell-programmin...ed-string.html
(Perderabo)
I tried the
echo abababab | sed 's/b/\/'


But didnīt work
Code:
messagem sed: command garbled: s/b/\/g

Iīm using solaris, I think awk or nawk is my way out.
Or Iīm doing some stupid mistake ( very possible Smilie)

Iīm accepting ideas for only replace the file string1 and not #string1, so If I run the program twice I donīt get any problem.

Last edited by Yogesh Sawant; 04-27-2009 at 02:56 PM.. Reason: added code tags
# 2  
Old 04-27-2009
SED - replace with new line didnīt work for solaris

Dear...

the problem is the new line where you have to enter new line literary so the command should be :-

sed 's,STRING1, #STRING1\
STRING2,' < filename > output_file

Last edited by ahmad.diab; 04-27-2009 at 10:03 AM..
# 3  
Old 04-27-2009
Quote:
Originally Posted by alcalina
I found the this topic

https://www.unix.com/shell-programmin...ed-string.html
(Perderabo)
I tried the
echo abababab | sed 's/b/\/'


But didnīt work
messagem sed: command garbled: s/b/\/g

Iīm using solaris, I think awk or nawk is my way out.
Or Iīm doing some stupid mistake ( very possible Smilie)
In Perderabo's post, the code looks like
Code:
echo abababab | sed 's/b/\
/g'

Notice that the /g' is in the next line i.e. you hit the Enter key on your keyboard after you type sed 's/b/\
# 4  
Old 04-27-2009
MySQL solved - thanks

thanks, It was a stupid problem mine
I was trying so hard to find one break line that do not think in enter


Sorry

Last edited by alcalina; 04-27-2009 at 10:13 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Crontab] didn't work

Hello, Here is my crontab # Reboot one Sunday out of 2 at 02:00 0 2 * * 0/2 /usr/bin/reboot 2017-04-16 2017-04-23 2017-04-30 and so on I tested my crontab here, it seems to work Http://cron.schlitt.info/index.php?c...=100&test=Test However on my distrib linux mageïa When I register... (4 Replies)
Discussion started by: amazigh42
4 Replies

2. Shell Programming and Scripting

SED and Solaris Append line to the end of File does not work

Hello, I have to add a new line at the end of a File on Solaris-System: I think my script should be right, because I evaluated it to other threads. However the script does not what I am expected it should do. My file might look like this: Line1 Line2 Line3 And my script could... (7 Replies)
Discussion started by: Timo_HR
7 Replies

3. UNIX for Dummies Questions & Answers

emulate aix 5.3 , how ....? pearpc didn't work

how to emulate aix 5.3 i had try pearpc , but it didn't work ... someone have some solution? thanks (1 Reply)
Discussion started by: prpkrk
1 Replies

4. SCO

Hard disk clone of OpenServer 5.0.0 didn't work, why?

Continuing saga of working on making a retail store more robust by creating a backup clone of the main server, a 1995 era :eek: PC running SCO OpenServer 5.0.0b and a discontinued Point of Sales (POS) software system. I have a PC of the same make and model. The CPU runs faster and it has a... (5 Replies)
Discussion started by: jgt10
5 Replies

5. Shell Programming and Scripting

sed replace not work Pls. help me

sed replace not work Pls. help me I used sed command in my file 66875964560@1982589 90825890001@90825890001@3@15/12/2007 14:25:14@22/03/2010 6:06:13@20/01/2010 3:28:39 66873064490@1925912 90259120001@90259120001@5@02/04/2009 1:51:31@30/10/2009 3:08:34@13/09/2009 8:24:33... (3 Replies)
Discussion started by: ooilinlove
3 Replies

6. Shell Programming and Scripting

Does Sed Search/Replace Work For Multiple Matches On The Same Line?

Hello, I would like to delete all the footnotes in all my htm files. Hence, I have to delete the whole font tag pairs, i.e. deleting everything between the begin/end font tags. I create a testfile, of which data parts of all four lines are the same except for the number of font tag pairs,... (3 Replies)
Discussion started by: cibalo
3 Replies

7. UNIX for Dummies Questions & Answers

starce didn't work

Hello, I am learning to debug in sgi-Irix6.5, after a core dump, I was adviced to perform a "strace", but I got the following information: ERROR: tracer already exists what shall I do now? Thanks a lot Daniel (0 Replies)
Discussion started by: lakeat
0 Replies

8. Shell Programming and Scripting

script to start DB didn't work, help

I have created a script to strat and shutdown Oracle 10g DB on Solaris automatically when UNIX reboot. In the begining, it worked well. All of sudden, the dbstart part didn't work, other 3 part for lsnrctl, emctl, isqlplusctl all worked fine. I think it was TNS_ADMIN variable got problem. Because... (0 Replies)
Discussion started by: duke0001
0 Replies

9. Shell Programming and Scripting

mail program on shell script didn't work, please advise.

Hi, everyone: I post a new thread because previous post may sink and I hope the new one can be caught by your eyes. I created a shell script and the script works fine. However, the mail program part on script didn't send email to my email box and it also didn't provide any traceable... (7 Replies)
Discussion started by: duke0001
7 Replies

10. Shell Programming and Scripting

script didn;t work in cron !!! @_@

Hi all, I am writing a script to monitor some processes existence in the system. It works perfectly by running the script manually in commend line. However, when I put it under cron to run it failed. Everything time when the variable is null in the if statment. it failed and quitted. Here is... (2 Replies)
Discussion started by: stancwong
2 Replies
Login or Register to Ask a Question