You are not logged in.

#1 2009-03-25 21:18:34

smartboyathome
Member
From: $HOME
Registered: 2007-12-23
Posts: 334
Website

[SOLVED] sed help please...

I'm trying to modify an XFWM theme, and need to run sed to replace colors with a phrase to make it "blend in" with the GTK theme. Unfortunately, it isn't working. Can anyone help?

Here is what I am trying to run:

sed -e 's/\#E6E6E6/\#E6E6E6 s active_color_2/g' *-active.xpm

The result of that gives me something similar to running cat *-active.xpm.

Last edited by smartboyathome (2009-03-25 21:49:53)

Offline

#2 2009-03-25 21:25:16

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: [SOLVED] sed help please...

manpage wrote:

-i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if extension supplied)

So just do "sed -i -e blah".

The default is for sed just to print the input (+changes) to STDOUT.


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#3 2009-03-25 21:27:55

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: [SOLVED] sed help please...

Use sed -i

Make sure -i doesn't have an argument though. sed -ie '...' FILENAME will make changes to FILENAMEe.

Offline

#4 2009-03-25 21:30:04

smartboyathome
Member
From: $HOME
Registered: 2007-12-23
Posts: 334
Website

Re: [SOLVED] sed help please...

Thanks, I'm a sed noob, first time using it. wink

Offline

#5 2009-03-25 21:31:00

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [SOLVED] sed help please...

the above should work but i'd script it:

edit that, the above will work and will work better, faster and more efficiently...

but i'd still script it wink

#!/bin/bash

find ./ -name '*-active.xpm' | while read file; do
  cp $file $file.orig
  cat $file | sed 's/\#E6E6E6/\#E6E6E6 s active_color_2/g' > temp
  mv temp $file
done

Last edited by brisbin33 (2009-03-25 21:39:20)

Offline

#6 2009-03-25 21:45:33

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: [SOLVED] sed help please...

@brisbin33: Did you know sed -i actually does that too, redirect the changes to a temporary file and move that back.

Offline

#7 2009-03-25 23:26:30

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [SOLVED] sed help please...

Procyon wrote:

@brisbin33: Did you know sed -i actually does that too, redirect the changes to a temporary file and move that back.

yeah, i kinda figured that when i saw -i will except a suffix (.orig .bak i presume).  linux thinks of everything

Offline

Board footer

Powered by FluxBB