Jose Torres Jose Torres - 1 year ago 85
Linux Question

find and replace value in SED linux

i have a file called form.php:


The purpose is to execute a shell script like this with sed:

$sh form.php 50

For obtain:


I tried this

sed -i "s/^\( *sleep\)\([^>]*\)</\1$2</" "$1"

but dont work...

Answer Source

You can use:

sed "s/sleep([^)]*)/sleep($2)/" "$file"

or this one:

sed "s/\(sleep\)([^)]*)/\1($2)/" "$file"

sed use BRE by default and ( or ) take as literal not as special regex meta character.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download