You are not logged in.

#1 2008-04-30 18:48:19

Bapman
Member
From: Ottawa, Canada
Registered: 2007-09-02
Posts: 140

[SOLVED] Help with sed command !

Hi,

I want to use sed to modify a source file. I use sed so that I can integrate it into a PKGBUILD.

I use this command :

sed -e 's/NEW_RESIZE_CODE 1/NEW_RESIZE_CODE 0/' guiconfig.h

It does exactly what I want. But now I want to directly modify the file and overwrite its content so I do :

sed -e 's/NEW_RESIZE_CODE 1/NEW_RESIZE_CODE 0/' guiconfig.h > guiconfig.h

But when I open the file, it is empty ! Note that it works if I use a different filename than the original input filename !!!

Any idea smile ?

Last edited by Bapman (2008-04-30 18:57:21)

Offline

#2 2008-04-30 18:52:05

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: [SOLVED] Help with sed command !

try:

sed -i 's/NEW_RESIZE_CODE 1/NEW_RESIZE_CODE 0/' guiconfig.h

Haven't been here in a while. Still rocking Arch. smile

Offline

#3 2008-04-30 18:56:46

Bapman
Member
From: Ottawa, Canada
Registered: 2007-09-02
Posts: 140

Re: [SOLVED] Help with sed command !

That's it ! Thanks a lot big_smile

Offline

#4 2008-04-30 18:57:18

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: [SOLVED] Help with sed command !

You're welcome!


Haven't been here in a while. Still rocking Arch. smile

Offline

#5 2008-04-30 20:59:01

bavardage
Member
Registered: 2008-02-17
Posts: 160

Re: [SOLVED] Help with sed command !

Heh I did the same thing recently whilst attempting to correct a typo in some schoolwork and wiped the file - luckily git came to the rescue.
Moral: backup files when playing with things you don't fully understand. Actually, backup files in general.

Offline

Board footer

Powered by FluxBB