PDA

View Full Version : posix reg expression



OOzypal
July 30th, 2007, 02:47 PM
How can I search for a complet line and pad it with /* and */. I mean let's say that I have this line


background-color:blue;

I would like to search for the whole line then change it to

/* background-color:blue; */

The line could be anything

HalcónMaltés
July 30th, 2007, 03:21 PM
If you're editing a text-based file, you may want to try the 'sed' command. Sed is a stream text editor, which has the replacing feature you seem to need. Take a look (http://lowfatlinux.com/linux-sed.html), then use the man pages to get some more. :)

rjack
July 30th, 2007, 03:40 PM
Something like this?

echo Hello World | sed 's%^.*$%/* & */%'
/* Hello World */

This will comment out all the lines containing "background-color:blue;"

sed 's%^background-color:blue;$%/* & */%'

Jessehk
July 30th, 2007, 05:20 PM
This would do it:


sed -e 's;^\(.*\)$;/* \1 */;'

OOzypal
July 30th, 2007, 09:07 PM
Actually, I am trying to use with bluefish custom menu replace.

I want to be able to highlight a text and comment it.