Computing.Net > Forums > Unix > wild card subtitue

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

wild card subtitue

Reply to Message Icon

Name: gotme
Date: June 8, 2009 at 19:31:41 Pacific
OS: unix
Subcategory: General
Comment:

Hi Experts:

I would like to do a wild card subtitution on a file. In this file, it contains these:
.f(we_rtf123_orty4);
.f(rf_RED_234_p23455oi);

I would like to global replace all the characters inside with blank. i.e f(we_rtf123_orty4); with .f( );

I need to use wild card since I have so many lines I need to replace and each of the word are unique and the word length are different in size. Any help you can provide is greatly appreciated.

Thanks,

gotme



Sponsored Link
Ads by Google

Response Number 1
Name: lankrypt0
Date: June 9, 2009 at 06:17:58 Pacific
Reply:

sed -e "s/(.*)/( )/g" < filename


0

Response Number 2
Name: gotme
Date: June 9, 2009 at 08:54:51 Pacific
Reply:

Thanks for the reply lankryt0. Unfortunatley, I go this message
sed: command garbled: s/(.*)/( )g

gotme


0

Response Number 3
Name: lankrypt0
Date: June 9, 2009 at 10:05:20 Pacific
Reply:

the command is: sed -e "s/(.*)/( )/g" < filename

you are missing the / before the g at the end


0

Response Number 4
Name: gotme
Date: June 9, 2009 at 11:43:00 Pacific
Reply:

Thanks for catching the error. A bit better but not what I want.
It is replacing all the word inside the bracket to blank but it also remove the .f. I want it to be like .f() not ().

Thanks.


0

Response Number 5
Name: lankrypt0
Date: June 9, 2009 at 12:09:36 Pacific
Reply:

strange, when I run the command, that is what I get:

user@machine:~/test> sed "s/(.*)/( )/g" < infile
.f( );
.f( );
.f( );
.f( );
.f( );
.f( );
user@machine:~/test> sed --version
GNU sed version 4.0.9

Infile looks like:

.f(we_rtf123_orty4);
.f(rf_RED_234_p23455oi);
.f(we_rtf123_orty4_asdf);
.f(rf_RED_234_p23455oi_sdasd);
.f(we_rtf123_orty4_we_rtf123_orty4);
.f(rf_RED_234_p23455oi_we_rtf123_orty4);


0

Related Posts

See More



Response Number 6
Name: gotme
Date: June 9, 2009 at 19:08:17 Pacific
Reply:

Thanks lankrypt0! It works after I ran it again. Don't know what happened. I appreciated all your assistance.

Gotme


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: wild card subtitue

Wild Cards in Windows www.computing.net/answers/unix/wild-cards-in-windows/1615.html

Wild Card in the if statment www.computing.net/answers/unix/wild-card-in-the-if-statment/7624.html

is there a wild card for pattern? www.computing.net/answers/unix/is-there-a-wild-card-for-pattern/8290.html