Sostituire stringhe in uno script bash con sed

From RVM Wiki
Jump to navigation Jump to search

Per sostituire un stringa in uno script bash, usare sed, lanciato come:

sed "s/originale/sostituito/"

Esempio:

#!/bin/bash
OGGETTO="Io mi chiamo pippo e voglio essere chiamato pippo"
echo Originale: $OGGETTO
OGGETTO=$(echo OGGETTO | sed "s/pippo/pluto/g"" )
echo Sostituito: $OGGETTO

RIferimenti