merging sed commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting merging sed commands
# 1  
Old 03-09-2011
merging sed commands

Hi,

I've a shell that uses two sed commands to tailor a file.

sed 's/ */ /g' | sed 's/%/%%/g'

Is it possible to merge this in to a single sed?

Thanks!
# 2  
Old 03-09-2011
Code:
sed -e 's/ */ /g' -e 's/%/%%/g'

# 3  
Old 03-09-2011
Or a little bit shorter:

Code:
sed -e 's/  */ /g;s/%/%%/g'

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested sed commands

Hi, I get the following response by gphoto2 and I would like to substract the index number of the current item. In this case 3. gphoto2 --get-config /main/imgsettings/iso Label: ISO Speed Type: RADIO Current: 200 Choice: 0 100 Choice: 1 125 Choice: 2 160 Choice: 3 200 Choice: 4 250 ..... (11 Replies)
Discussion started by: Nic2015
11 Replies

2. Shell Programming and Scripting

Merging data from col 3 to col2 with awk or sed

Dear Friends, I have a file in which lists State and Phone numbers. Does anybody have a solution in which to take the data from col3 and place it on col2? AK 2988421640 9077467107 AK 2998266711 2069239034 AK 2983804242 2069239034 AK 2960407849 AK ... (3 Replies)
Discussion started by: liketheshell
3 Replies

3. Shell Programming and Scripting

Grouping sed commands

Hello, would you please help me with why my SED command file is outputting the entire input file instead of only the text that I'm trying to block? cat testfile O 111111111-00 DUE-DATE METHOD: FREQUENCY: O 222222222-00 DUE-DATE METHOD: FREQUENCY: O 333333333-02 DUE-DATE METHOD:... (4 Replies)
Discussion started by: lneedh1
4 Replies

4. Shell Programming and Scripting

Running sed commands

Hello I need to run some sed commands but it involves "/" in the substitute or delete, any ideas how I get round the problem. Example: cat file1.txt | sed -e '/</Header>/d' > file2.txt This errors due to the forward slash before the Header text. Thanks (3 Replies)
Discussion started by: Dolph
3 Replies

5. Shell Programming and Scripting

Merging output of two commands for a third command

I'm not sure if this is even possible but I'm hoping to avoid generating a temporary file. What I'm trying to do is append a perl command to the start of a list created by grep, then send the entire thing to mail. This is mainly to ensure that something isn't wrong when the list is blank, but it... (2 Replies)
Discussion started by: Chthonic
2 Replies

6. Shell Programming and Scripting

Merging previous line using sed

I've been trying to merge a previous line when I find a pattern using sed with no luck. Maybe someone can help me. I am trying to find </Endtag>. Once I find that, I want to merge the previous line with the current line. I can do it with the next line with using N in sed but not previous.... (6 Replies)
Discussion started by: quixoticking11
6 Replies

7. Shell Programming and Scripting

Using variables in sed commands

Hi there, I need to be able to put the hostid of my box into a file (replacing the text "enter_hostid_here" so i tried sed -e 's/enter_hostid_here/`hostid`/g' inputfile > outputfile but it takes the `hostid` literally as text .....how can I get this info into the file (ideally in a single... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

8. UNIX for Dummies Questions & Answers

combining sed commands

I would like to change the lines: originalline1 originalline2 to: originalline1new originalline1newline originalline2new originalline2newline To do this, id like to combine the commands: sed 's/^/&new/g' file > newfile1 and sed '/^/ a\\ newline\\ \\ (2 Replies)
Discussion started by: Dave724001
2 Replies

9. Shell Programming and Scripting

multiple sed commands

hello! I have a few sed commands sed '/^$/d' < $1 > tmp.t sed '/^ \{3,\}/d' < tmp.t > tmp1.txt ..... how can I write them in a single line? sed '/^$/d' < $1 > | '/^ \{3,\}/d' < $1 > tmp1.txt any idea? thanks. (5 Replies)
Discussion started by: george_
5 Replies

10. Shell Programming and Scripting

sed commands

I have a configuration file that when a certain script runs in updates. I want to use sed and can't seem to get the syntax right. A line from the configuration file looks like: DATE=20040909 12:00:10 When the script is run I want to change the date and time, i.e. removing the previous... (7 Replies)
Discussion started by: dbrundrett
7 Replies
Login or Register to Ask a Question