new lines symbols in sed?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting new lines symbols in sed?
# 1  
Old 11-20-2006
new lines symbols in sed?

I want to edit a huge script file using sed. How can I add the new lines symbols in the red colored places?

sed -e "s/test -z "$x"/if test -z "$x" then echo -1; \n else \n/g"
# 2  
Old 11-21-2006
You can do the work with awk :
Code:
awk "{ gsub(/test -z $x/, \"if & then echo -1; \n else \n\") ; print}"

Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Removing unwanted symbols with sed

I would like produce blue, green, red, yellowfrom"blue:,*green:,*red:,*yellowI can remove the colon with echo "blue:,*green:,*red:,*yellow" | sed 's/://g'which givesblue,*green,*red,*yellowbut when I try echo "blue:,*green:,*red:,*yellow" | sed 's/://g'; 's/*//g'I get bash: s/*//g: No such... (9 Replies)
Discussion started by: Xubuntu56
9 Replies

2. Shell Programming and Scripting

Sed, how replace specific symbols between two patterns

I have a big xmltv file with many lines like: <?xml version="1.0" encoding="UTF-8"?> <tv> <channel id="channel 1 +3HD"> <display-name lang="it">channel +3HD</display-name> <icon src="http://mywebsite.com/dsgbnjfdc65657/channel +3HD.png" /> ... (8 Replies)
Discussion started by: Tapiocapioca
8 Replies

3. Shell Programming and Scripting

ksh sed - Extract specific lines with mulitple occurance of interesting lines

Data file example I look for primary and * to isolate the interesting slot number. slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'` Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk... (2 Replies)
Discussion started by: popeye
2 Replies

4. UNIX for Dummies Questions & Answers

sed command for removing symbols

Hi I am trying to remove all the symbols in a file (testfile1) and using the below command to do that. Its not working for me. Can you help me on what is wrong with below script? I want to retain only alphabets in a file and remove all the symbols like *:.+= etc sed 's/^.//g' testfile1 > testfile2 (4 Replies)
Discussion started by: sandeepcm
4 Replies

5. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

6. Shell Programming and Scripting

Sed/awk to delete single lines that aren't touching other lines

Hello, I'm trying to figure out how to use sed or awk to delete single lines in a file. By single, I mean lines that are not touching any other lines (just one line with white space above and below). Example: one two three four five six seven eight I want it to look like: (6 Replies)
Discussion started by: slimjbe
6 Replies

7. Shell Programming and Scripting

sed show lines text between 2 blank lines

I have a file like blah blah blah blah this is the text I need, which might be between 1-4 lines, but always has a blank line above and below it, and is at the end of the text file the code tags don't show the trailing blank line. I started by deleting the last blank line with: ... (2 Replies)
Discussion started by: unclecameron
2 Replies

8. 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

9. Shell Programming and Scripting

remove accents and symbols with sed

Hi, I would like to know how could I remove accentes and the symbols: º and ª of a text file with sed. Whis this command doesn't works :-( sed "s/í/i/g" filename Many thanks and sorry for my english! (7 Replies)
Discussion started by: mierdatuti
7 Replies

10. Shell Programming and Scripting

How to replace symbols by position using SED

Hi all, I need your help. For example I have string in file.txt: -x -a /tmp/dbarchive_NSS_20081204 -f 900 -l 1 2008/12/04 2008/12/04 So, I need to replace symbols from (for e.g.) position 26 till 33 with symbols which I have in file replace.txt And I have no idea how to do it. If... (1 Reply)
Discussion started by: nypreH
1 Replies
Login or Register to Ask a Question