sed and character return problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed and character return problem
# 1  
Old 09-18-2008
sed and character return problem

Hi,
I have a problem with sed. It doesn't recognize the "\n" character. It substitudes an "n", instead of introducing a new line.
This doesn't happend with print $ print "test \n \n" (it deos introduce two lines after hello)
(AIX)

$ sed s/bc/\n/g test.1 >test.2
$ cat test.1
bcdefg
abcdefgafj

$ more test.2
ndefg
andefgafj
The same happend with:
sed 's/bc/\n/g test.1' >test.2
sed "s/bc/\n/g" test.1 >test.2
sed s/"bc"/"\n"/g test.1 >test.2
Anybody has an idea?
thanks
S
# 2  
Old 09-18-2008
# 3  
Old 09-18-2008
this should work..
Quote:
sed -e 's/searchpattern/(press enter here)
/g' filename
# 4  
Old 09-19-2008
Code:
awk '{ sub("bc", "\n"); print }' File Name

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies

2. Shell Programming and Scripting

Return the list of file name prefix with first 6 character

Good day people, Kindly advice what is the operator/command that I should try out to if I am about to return a list of prefix of my filename with first 6 character. I understand I could use sed to retrieve the first 6 charter itself. but i wonder if there is any aix command allow me to loop... (4 Replies)
Discussion started by: cielle
4 Replies

3. UNIX for Dummies Questions & Answers

Grep to return lines not containing a character

Hello , this is my first topic cause I need your little help:( I got .txt file, and I want to find lines without letter 'a', so im writing: grep "" list.txt (list.txt is the file of course) and i have no idea why it's not working because it shows lines with a. (1 Reply)
Discussion started by: bbqtoss
1 Replies

4. Shell Programming and Scripting

Return part of string after X numbers of a character

My input strings look something like this: /dev/vs/dsk/group/vol I want to print just "group" out of the line... which is always found between the 4th and 5th "/" in the string. I figure I have to use awk, sed, or some combination to do this, but I've searched the forums and can't find... (2 Replies)
Discussion started by: ltricarico
2 Replies

5. Shell Programming and Scripting

Problem with using a sed to add escape character \ before $ and ' symbols

Hi all, I've got a problem with sed. Want to use it to add escape character \ before $ and ' symbols so condition='1'$some will become condition=\'1\'\$some echo "condition='1'$some" | sed 's/\($\)/\\\1/g' is not working properly. Can somebody help me with this please? Regards,... (7 Replies)
Discussion started by: johny_be_good
7 Replies

6. Shell Programming and Scripting

In Sed how can I replace starting from the 7th character to the 15th character.

Hi All, Was wondering how I can do the following.... I have a String as follows "ACCTRL000005022RRWDKKEEDKDD...." This string can be in a file called tail.out or in a Variable called $VAR2 Now I have another variable called $VAR1="000004785" (9 bytes long), I need the content of... (5 Replies)
Discussion started by: mohullah
5 Replies

7. Shell Programming and Scripting

carriage return or funky character stuck in my variables - help :)

My variables contain carriage returns... or something. Here is the line in my xml file of interest: <tmp>72</tmp> And here is the line that extracts the 72 from it: REAL=`grep '<tmp>' test.xml | sed -e 's/^ *<tmp>//' -e 's/<\/tmp>//' -re 's/(N|n|A|a|\/)/U/g'`If echo the variable it... (5 Replies)
Discussion started by: audiophile
5 Replies

8. Shell Programming and Scripting

Substituting carriage return followed by newline character - HELP

-------------------------------------------------------------------------------- Hi All I have a field being returned from the DB that when opened in Vi shows a ^M before the rest of the field is displayed on the next line. I need it so that the only newline character is the end of the... (14 Replies)
Discussion started by: djkane
14 Replies

9. UNIX for Dummies Questions & Answers

Substituting carriage return follwed by newline character - HELP!

Hi All I have a field being returned from the DB that when opened in Vi shows a ^M before the rest of the field is displayed on the next line. I need it so that the only newline character is the end of the line since I need to transform my file into an Excel report. Thus my idea is to... (1 Reply)
Discussion started by: djkane
1 Replies

10. Shell Programming and Scripting

Test return character.

Hi, in my korn shell I have this code: typeset -uL1 rc read rc?"Insert Y=Yes (default) or N=No >>" If I press enter without value I wish to set rc=Y. This is my default. This test: if ] then .... Do not work. I hope in your help. Thanks in advance. Regards, Giovanni (3 Replies)
Discussion started by: gio123bg
3 Replies
Login or Register to Ask a Question